Search Results

Search found 2 results on 1 pages for '1984isnotamanual'.

Page 1/1 | 1 

  • why can't I call methods on a for-yield expression?

    - by 1984isnotamanual
    Say I have some scala code like this: // outputs 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 println( squares ) def squares = { val s = for ( count <- 1 to 10 ) yield { count * count } s.mkString(", "); } Why do I have to use the temporary val s? I tried this: def squares = for ( count <- 1 to 10 ) yield { count * count }.mkString(", ") That fails to compile with this error message: error: value mkString is not a member of Int def squares = for ( count <- 1 to 10 ) yield { count * count }.mkString(", ") Shouldn't mkString be called on the collection returned by the for loop?

    Read the article

  • Will Sytem.currentTimeMillis always return a value >= previous calls?

    - by 1984isnotamanual
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#currentTimeMillis() says: Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds. It is not clear to me if I am guaranteed that this code will always print ever increasing (or the same) numbers. while (1) { System.out.println(System.currentTimeMillis() ); }

    Read the article

1