Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
VB.NET
Perl
COBOL
Pascal
FORTRAN
BASIC
Ada
C++
Scala
ASP.NET
 C
 :) Hot Jobs
 
 :) Latest Articles


  

 


Yield keyword in Scala?
Question Posted on 28 Feb 2021

Home >> Programming Languages >> Scala >> Yield keyword in Scala?




Yield keyword in Scala?
We use Yield keyword as a Loop in scala. Yield keyword will returns a result once the loop iteration is complete. Here for loop used buffer internally stored iterated result and when iterations is finisihed it yields the result from that buffer. And this will not work like imperative loop. Because type of collection which is returned is of same type that we tend to were iterating over, Therefore a Map yields a Map, a List yields a List, and so on. And syntax for Yield keyword is given below

var result = for{ var x <- List }
yield x


In above code we have used curly braces that keep the variable conditions and result is variable where all the values of x are kept within the form of collection.

Below are some silent features of Yield:-
(1)It is used as a Loop.
(2)It produced value for each iteration.
(3)It supports the use of Map, FlatMap, and Filters along with nomads.
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
what is use of Tuples in Scala?
Syntax to Append single and multiple data element in list in Scala?
Difference between Java, Scala, Python and R
Define Closure in Scala with example?
Different types of variables in Scala explain them?






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |