Skip to content

Instantly share code, notes, and snippets.

@katsuhide
Created October 13, 2013 07:14
Show Gist options
  • Save katsuhide/6959052 to your computer and use it in GitHub Desktop.
Save katsuhide/6959052 to your computer and use it in GitHub Desktop.
ループ文、IF文など
## while文
while 条件式 do
実行する処理1
実行する処理2
end
## for文
for 変数 in オブジェクト do
実行する処理1
実行する処理2
end
## 配列や範囲オブジェクトでのループ
オブジェクト.each{|変数|
実行する処理1
実行する処理2
}
## Integerオブジェクトでのループ
10.times{|変数|
実行する処理1
実行する処理2
}
## if文
if age >= 12 then
print "adult fee\n"
else
print "child fee\n"
end
gender = if foo.gender == "male" then "male" else "female" end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment