Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created August 28, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/aed7821fb2b808a07a09 to your computer and use it in GitHub Desktop.
Save chuck0523/aed7821fb2b808a07a09 to your computer and use it in GitHub Desktop.
# array
for color in ["red", "blue", "pink"]
console.log color
# 1行で書くとこんな感じ
console.log color for color in ["red", "blue", "pink"]
# whenで条件指定
console.log color for color in ["red", "blue",
"pink"] when color isnt "blue"
# "red" "pink"
# indexを取る
console.log "#{i} : #{color}" for color , i in ["red", "blue", "pink"]
###
0 : red
1 : blue
2 : pink
###
# object
result =
chuck : 50
man : 20
Hello : 40
for name, score of result
console.log "#{name} : #{score}"
###
chuck : 50
man : 20
Hello : 40
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment