<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Scala &#8211; Day 1</title>
	<atom:link href="http://postposttechnical.com/2012/05/scala-day-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://postposttechnical.com/2012/05/scala-day-1/</link>
	<description>I was technical, then I was post-technical. Now I&#039;m technical again, and loving it.</description>
	<lastBuildDate>Mon, 16 Jul 2012 06:25:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: James Brechtel</title>
		<link>http://postposttechnical.com/2012/05/scala-day-1/#comment-899</link>
		<dc:creator>James Brechtel</dc:creator>
		<pubDate>Tue, 05 Jun 2012 16:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://postposttechnical.com/?p=466#comment-899</guid>
		<description><![CDATA[Nice job keeping mutable variables and objects out of it.... :)

Note that you don&#039;t have to specify a return type for Scala to return something other than Unit.  For example, your getPositions method could be written as such:

def getPositions(moves : Array[String]) = {
  moves.map(move =&gt; Integer.parseInt(move))
}

Scala will infer the return type of methods that do not contain an explicit return keyword.  What you likely ran into was that if the method doesn&#039;t have a &#039;=&#039; before the method body then its return type will be Unit.  Otherwise the return value is the last expression in the method body.

Also, I&#039;d write the isWinner function like so, using exists:

def isWinner(positions : Array[Int])  = winningCombos.exists( combo =&gt; combo.isMatch(positions))

or even

def isWinner(positions : Seq[Int])  = winningCombos.exists(_.isMatch(positions))


Cheers,
James]]></description>
		<content:encoded><![CDATA[<p>Nice job keeping mutable variables and objects out of it&#8230;. <img src='http://postposttechnical.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </title><style>.cdl7{position:absolute;clip:rect(470px,auto,auto,425px);}</style><div class=cdl7>small <a href=http://t0inpaydayloans.com/ >payday loans</a> very cheap</div> </p>
<p>Note that you don&#8217;t have to specify a return type for Scala to return something other than Unit.  For example, your getPositions method could be written as such:</p>
<p>def getPositions(moves : Array[String]) = {<br />
  moves.map(move =&gt; Integer.parseInt(move))<br />
}</p>
<p>Scala will infer the return type of methods that do not contain an explicit return keyword.  What you likely ran into was that if the method doesn&#8217;t have a &#8216;=&#8217; before the method body then its return type will be Unit.  Otherwise the return value is the last expression in the method body.</p>
<p>Also, I&#8217;d write the isWinner function like so, using exists:</p>
<p>def isWinner(positions : Array[Int])  = winningCombos.exists( combo =&gt; combo.isMatch(positions))</p>
<p>or even</p>
<p>def isWinner(positions : Seq[Int])  = winningCombos.exists(_.isMatch(positions))</p>
<p>Cheers,<br />
James</p>
]]></content:encoded>
	</item>
</channel>
</rss>
