Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Tags
#odersky-programming-in-scala-1ed #scala
Question
What does to stand for in this example?

for (i <- 0 to 2)
  print(greetStrings(i))
Answer
a method call (0).to(2)
if a method takes only one parameter, you can call it without a dot or parentheses.

Tags
#odersky-programming-in-scala-1ed #scala
Question
What does to stand for in this example?

for (i <- 0 to 2)
  print(greetStrings(i))
Answer
?

Tags
#odersky-programming-in-scala-1ed #scala
Question
What does to stand for in this example?

for (i <- 0 to 2)
  print(greetStrings(i))
Answer
a method call (0).to(2)
if a method takes only one parameter, you can call it without a dot or parentheses.
If you want to change selection, open document below and click on "Move attachment"

Next Steps in Scala
t reassign greetStrings to a different array; greetStrings will always point to the same Array[String] instance with which it was initialized. But you can change the elements of that Array[String] over time, so the array itself is mutable. <span>The final two lines in Listing 3.1 contain a for expression that prints out each greetStrings array element in turn: for (i <- 0 to 2) print(greetStrings(i)) The first line of code in this for expression illustrates another general rule of Scala: if a method takes only one parameter, you can call it without a dot or parentheses. The to in this example is actually a method that takes one Int argument. The code 0 to 2 is transformed into the method call (0).to(2).[1] Note that this syntax only works if you explicitly specify the receiver of the method call. You cannot write "println 10", but you can write "Console println 10&quot

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.