Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

February 18, 2012

Variations for computing results from sequences in Scala

Filed under: Functional Programming,Scala — Patrick Durusau @ 5:26 pm

Variations for computing results from sequences in Scala

From the post:

A common question from students who are new to Scala is: What is the difference between using the map function on lists, using for expressions and foreach loops? One of the major sources of confusion with regard to this question is that a for expression in Scala in not the equivalent of for loops in languages like Python and Java — instead, the equivalent of for loops is foreach in Scala. This distinction highlights the importance of understanding what it means to return values versus relying on side-effects to perform certain computations. It also helps reinforce some points about fixed versus reassignable variables and immutable versus mutable data structures.

Continuing with the FP theme. Don’t miss the links to additional tutorial materials on Scala at the end of this post.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress