Scala Code Trollin’

So, we’ve all heard of “flatmap that sh**”, right? The new, functional, hipster way of saying

You’re doing it wrong

Since we don’t really care about dogma and functional religion that much, let’s just start trolling a little (it’s so much easier anyway), with Scala code. Check out the following piece of useful Scala code, which does compile:

def C = Seq(1, 2, 3)
def Windows = 0
def WAT = (C:\Windows)                                                           /* OK, we also need this */ (_)

Awesome, right? I leave it up to you to figure out what the above piece of code does.

Don’t believe it? Or don’t care about the puzzle? Here’s the solution on ScalaFiddle.

This discussion was inspired by CTMMC

5 thoughts on “Scala Code Trollin’

  1. That’s why I like Python, I can read anyone’s code with no effort, even when using libs that I’ve never heard about.

    The more we diverge from the C-style syntax the more it’s difficult to find people for maintaining a given code-base.

    1. Don’t tell me. Apart from working on jOOQ, I’m currently also working extensively with PL/SQL. What an awesome language. Case insensitivity rocks! ;-)

    2. Python can be obfuscated:
      also dict/list/generator expressions can be used in non intuitive ways. Odd uses of getattribute can add significant complexity. Add metaclassing and all bets are off.
      Most languages have features that should be used judiciously, scala probably has more of them than python since you can write DSLs, but probably fewer than other languages like Perl. Anyways good programmers are ones who can write code other people understand, the language is secondary imo.

Leave a Reply