Created
February 16, 2013 17:56
-
-
Save ozw-sei/4967934 to your computer and use it in GitHub Desktop.
Scala勉強中なう--変数と制御文-- ref: http://qiita.com/items/3b398c6688085ba27a36
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
text = "World,Hello!" | |
//こんな風に値を変えようとすると怒られます。 |
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
var num = 1 | |
__//変数なので、後から値を変えることもできあmす。__ | |
num = 2 |
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
val ten:Int = 10 |
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
def max(x:Int,y:Int):Int 等号 | |
if(x>y) x //X返します | |
else y //y返します | |
} |
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
var i =0 | |
while(i<args.length){ | |
println(args(i)) | |
i+=1 | |
} |
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.args.foreach(arg => println(arg))//配列の要素を抽出して出力 | |
2.args.foreach(println)//引数に関数を投げてます | |
3.for(arg <- args) println(arg) |
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
var i =0 | |
while(i<args.length){ | |
if(i != 0){ | |
print(" ") | |
} | |
print(args(i)) | |
i += 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment