タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

CoffeeScriptとforに関するnibushibuのブックマーク (1)

  • CoffeeScriptのFor文 - Shut the fuck up and write some code

    すんごい初歩の話。 基形は for i in [0..9] console.log "index="+i[]内で範囲を指定します。 for文で配列からデータ取り出すときは for i in [0..hogehoge.length-1] console.log "value="+hogehoge[i]とか //配列からデータ取り出す for i,value of hogehoge console.log valueとかでいいんですが、 index値をつかって計算させたりとかした場合 for [値],[インデックス] in [配列] という書き方が一番シンプルで使えます。 arr = ["a", "b", "c", "d", "e"] for val, i in arr console.log "#{i}: #{val}""hogehoge.length-1" みたいな書き方で配列の個数を指

    CoffeeScriptのFor文 - Shut the fuck up and write some code
  • 1