scalapuzzlers / scalapuzzlers.github.com

Github Pages behind scalapuzzlers.com
www.scalapuzzlers.com
161 stars 53 forks source link

NL #155

Open som-snytt opened 5 years ago

som-snytt commented 5 years ago

Someone said, "I was surprised this isn't on scalapuzzlers.com."

Which should go on the next version of the t-shirt.

I numbered it 26 because sadly, now that scalaz is not in the community build, it will probably never get a puzzler. But on the upside, that is a feature.

I was surprised to find recent commit activity! All that dust must make you sneeze.

demobox commented 5 years ago

Is there some way this can be done in the REPL (e.g. using :paste -raw), or does it require scalac?

I ask since, in general, the "rule" for puzzlers has been that they are a self-contained piece of code you can run in the REPL.

som-snytt commented 5 years ago

Rules are made to be broken.

Also, it's a chance to branch out into scala script runner puzzlers.

som-snytt commented 4 years ago

Hey, that's not bad. The text is muddied with alternatives, and in fact it looks better straight in REPL as suggested:

scala> :pa
// Entering paste mode (ctrl-D to finish)

class C
/* This is a long
 * commentary.

 */
{
  println("""This is a long
commentary.

""")
}

// Exiting paste mode, now interpreting.

This is a long
commentary.

defined class C

scala> new C
res5: C = C@1fc4483f

This behavior is known but not widely complained about because no one writes comments.

demobox commented 4 years ago

This behavior is known but not widely complained about because no one writes comments.

Deprecation candidate? ;-)

As regards the example, is the paste mode version in line with what we'd expect from the original example? The way I was reading the puzzler, that was the version that didn't compile?

som-snytt commented 4 years ago

It's the same as

class C ; println("text")

and you see output right away.

I wonder if "Newline Cinema" is still in business? It would make a good title.

Also, same behavior in doti! The next edition of the book can have one of those star-shaped stickers: "Certified for Scala 3!"