Shellでいうseq
コマンドみたいなやつでしょうかね。
for(i <- 1 to 10) { print(i) }
しかし事件が起きる
scala> val test:Integer = 5 test: Integer = 5 scala> val test2:Integer = 10 test2: Integer = 10 @* ??? *@ scala> for(i <- test to test2) { print(i) } <console>:10: error: value to is not a member of Integer for(i <- test to test2) { print(i) } ^ @* ??? *@ scala> for(i <- {test} to test2) { print(i) } <console>:10: error: value to is not a member of Integer for(i <- {test} to test2) { print(i) } ^
なんかよくわからんぞ。
しかし、Int
型に戻したらできた。
scala> for(i <- test.toInt to test2) { print(i) } 5678910
理由はわからん!どやっ!(`・ω・)=3