Created
March 5, 2014 10:21
-
-
Save keizo042/9364719 to your computer and use it in GitHub Desktop.
九九を書いてみた。けどifのところが気持ち悪い。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1 to 10)foreach( | |
x => (1 to 10)foreach( | |
y =>if(y !=10) print(x * y+ "\t") else println(x *y + "\t") | |
) | |
) |
そちらのほうが読みやすくて無駄のない良いコードですね。
{}と()の扱いの違いを把握する必要がありそうです。
ありがとうございます。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こんにちは。if使わないように書き換えてみました。
{x => ... }
形式の場合、
...
部分に複数の式を並べて書くことができるのがミソです。https://gist.github.com/kmizu/9364793