scala中写for循环_Scala中的for循环

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循环具有特定用途,并且可以根据用户需要在代码中使用。 他们是,

  1. for loop using ranges

    for循环使用范围

  2. for loop with collections

    与集合循环

  3. for loop with filters

    带过滤器的循环

  4. for loop with yield

    带收益的循环

  5. 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循环

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值