scala中写for循环
Scala中的for循环 (for loop in Scala)
for loop in Scala is used to execute a block of code multiple numbers of times. It executes the block n number of times where n is specified by some integer initialized before the start of the loop. This means the programmer knows the exact number of time the loop is going to execute beforehand.
Scala中的for循环用于多次执行代码块。 它执行块n次,其中n由循环开始之前初始化的某个整数指定。 这意味着程序员可以事先知道循环要执行的确切时间。
In Scala, there are many types of valid for loops that have specific usage and can be used in code as per user need. They are,
在Scala中,有许多类型的有效for循环具有特定用途,并且可以根据用户需要在代码中使用。 他们是,
for loop using ranges
for循环使用范围
for loop with collections
与集合循环
for loop with filters
带过滤器的循环
for loop with yield
带收益的循环
for loop using by keyword
for循环使用关键字
1)循环使用范围 (1) for loop using ranges)
A loop with that integrates within a range of values of its counter is for loop using ranges.
一个在其计数器的值范围内积分的循环用于使用range的循环 。
Syntax:
句法:
for(var i
The Range here is a range of numbers. There are two ways to define range in a for loop.
Using to keyword to define the range, i to j.
Syntax:
翻译自: https://www.includehelp.com/scala/the-for-loop-in-scala.aspx
scala中写for循环