12 June 2013

Scala notes 10: yield , for yield expression , for comprehension and etc.

Information: THIS IS NOT TUTORIAL.
Scala notes is series of my "side comments" that can be useful during learning Scala.

Their contains bunch of information about interesting bits, explanation of things that i didn't come across yet or attempt to explain things which i didn't understand.


yield sounds interesting .... but what's that?

When i saw yield, i think it is a yell ( A loud, sharp cry, esp. of pain, surprise, or delight; a shout.).Shouting for loop sounds fascinating.Yield however is :


yield (IN SCALA * ) is a result ( as collection ) from for loop


Yield in Scala is just a  syntactic sugar** feature.
(It means that  this feature was  added to make code readability easier or make code better self-explanatory. It can be replaced easily by any map collection, see this post on stackoverflow ,where it is well explained : http://stackoverflow.com/questions/1052476/what-is-scalas-yield/1059501#1059501)


Yield  -  ( plon,uzysk,wydobycie)

  It has different meaning in some other languagues.
**  "syntactic sugar  - In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer." Wikipedia ( http://en.wikipedia.org/wiki/Syntactic_sugar ) 

Resources:
http://stackoverflow.com/questions/1052476/what-is-scalas-yield/1059501#1059501
http://ofps.oreilly.com/titles/9780596155957/RoundingOutTheEssentials.html
http://en.wikipedia.org/wiki/Syntactic_sugar


No comments:

Post a Comment