Question
What is the use of ‘yield’ keyword in scala’s for-comprehension construct?

Answers

We can use ‘yield’ keyword in Scala’s for-comprehension construct. ‘for/yield’ is used to iterate a collection of elements and generates new collection of same type. It does not change the original collection. It generates new collection of same type as original collection type.
For example, if we use ‘for/yield’ construct to iterate a List then it generates a new List only.
scala> val list = List(1,2,3,4,5)list: List[Int] = List(1, 2, 3, 4, 5)scala> for(l <- list) yield l*2res0: List[Int] = List(2, 4, 6, 8, 10)   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Which OS should I use?
  • Q What kind of brushed does silverlight support?
  • Q How did Washington try to improve morale in the Continental Army in late 1776 and early 1777? (A)French 1st Sergeant Davis (B)Prussian drillmaster Baron von Steuben (C)Englishman, John Locke (D)America's own, George Washington
  • Q Connection-oriented protocols in the TCP/IP suite are implemented in the: A. transport layer. B. application layer. C. physical layer. D. network layer.
  • Q Which are the two colours that used in Kannada flag?
  • Q Which two cities became capitals of two countries in 1911?
  • Q Stephanie Powers was Girl from UNCLE characters name
  • Q What communication disorders do you have experience in working with?
  • Q Explain about designing strategy of a control unit coded on vertical code?
  • Q Which version of my browser should i use?
  • Q Tell me about the most effective presentation you have made.