crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Yield keyword in Scala?
Question Posted on 28 Feb 2021Home >> 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



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




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?






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap