Tag Archives: pattern matching

Matching a combination of class and trait in Scala

While doing some development with Scala I discovered that it is possible to match combinations of a class and traits. It might seem obvious if you already know it, but I didn’t. What happened is that I needed something like … Continue reading

Posted in scala | Tagged , , , , , , , | Leave a comment

Scala Problem Number Five

From the Scala 99 Problems, the problem number five goes like this: P05 (*) Reverse a list. Example: scala> reverse(List(1, 1, 2, 3, 5, 8)) res0: List[Int] = List(8, 5, 3, 2, 1, 1) Starting with the obvious solution, using … Continue reading

Posted in scala | Tagged , , , , , , | Leave a comment

Matching a range of numbers in Scala

Hi everybody! Yesterday I did a presentation about Scala at Globalcode. It was very nice, thank you all who attended! Now, one of the things I liked the most was the final part when people started making questions. I must … Continue reading

Posted in scala | Tagged , , , , , , | 1 Comment

A Scala script for processing files

This time, we will approach Scala through a different angle: that of a script file. If you see Scala solely as a ‘normal’ programming language, this should demonstrate that Scala offers more possibilities than you knew. The code I’ll show … Continue reading

Posted in scala | Tagged , , , , , , , | 4 Comments

Scala Problem Number Two

Following with my take on the Scala 99 Problems that I started here, lets talk a little bit about the second one. Here is the problem definition, from the original page: P02 (*) Find the last but one element of … Continue reading

Posted in scala | Tagged , , , , | 1 Comment

Ninety-Nine Scala Problems

Listening to a few different podcasts (The Java Posse among them), I found out about Ninety-Nine Scala Problems. As the description on the site says, it is an adaptation of the original Ninety-Nine Prolog Problems. I find the idea very … Continue reading

Posted in scala | Tagged , , , , | 1 Comment

Scala Pattern Matching: the reason to fall in love with Scala

Scala has a lot of interesting features and, among them, one of the most interesting ones is Pattern Matching. If you still need a reason to try Scala this is the one. Actually, I might be exaggerating a little bit, … Continue reading

Posted in scala | Tagged , , , , , | 2 Comments