Continuing with the posts on Scala where we implemented Guessing game in imperative style and a in a couple of ways using the functional style, let’s implement it using pattern matching facility. Pattern matching provided in Scala is one of […]
In the previous post, we created the GuessingGame as a functional object that was immutable. It was a little heavy as every operation resulted in a new object. Let’s refactor it a but and see where we land. All that’s […]
In the earlier post on Scala, we created the Guessing Game class using imperative style. Now you’ve the GuessingGame class implemented using functional style. This is the first attempt in doing that. Couple of points to keep in mind here […]
Here’s a simple guessing game program using Scala’s imperative style and not functional style. class GuessingGame{ private var target:Int = (Math.random()*100).asInstanceOf[Int] var attempts:Int = 0 var message:String = "" var gameOver:Boolean = false def play(guess:Int):Unit= { attempts += 1 if(guess […]
I generally like to pick up one new language and technology every year. And these days the language that has me hooked is Scala. My interest in Scala shot up after the advent of social media web sites where concurrency […]