Using Streams in Scala

Currently there is an interesting discussion happening at the Vienna Scala Enthusiasts google group about using streams in Scala. One short puzzler for you:

val s = None #:: Stream.continually(Some(“A”))
val l = None :: Some(“A”) :: Some(“A”) :: Nil
s.take(3) == l

What does the Scala REPL output for the last expression?
a) true
b) false
c) compiler error
d) none of the above

For a discussion please see this message at the Vienna Scala Enthusiasts google group.

Note: A lot of Scala puzzlers are available at http://scalapuzzlers.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s