You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val newSalaries = salaries.map(x => x * 2) // List(40000, 140000, 80000)
56
+
```
57
+
{% end tab %}
58
+
59
+
{% tab 'Scala 3' for=map_example_2 %}
60
+
```scala
46
61
valsalaries=Seq(20_000, 70_000, 40_000)
47
62
valnewSalaries= salaries.map(x => x *2) // List(40000, 140000, 80000)
48
63
```
49
64
{% end tab %}
50
65
51
66
{% end tabs %}
67
+
52
68
Notice how `x` is not declared as an Int in the above example. That's because the
53
69
compiler can infer the type based on the type of function map expects (see [Currying](/tour/multiple-parameter-lists.html)). An even more idiomatic way to write the same piece of code would be:
0 commit comments