mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Added warning on return usage
This commit is contained in:
parent
6027c90c90
commit
d7672a2bc5
@ -198,7 +198,9 @@ weirdSum(2, 4) // => 16
|
||||
|
||||
|
||||
// The return keyword exists in Scala, but it only returns from the inner-most
|
||||
// def that surrounds it. It has no effect on anonymous functions. For example:
|
||||
// def that surrounds it.
|
||||
// WARNING: Using return in Scala is error-prone and should be avoided.
|
||||
// It has no effect on anonymous functions. For example:
|
||||
def foo(x: Int): Int = {
|
||||
val anonFunc: Int => Int = { z =>
|
||||
if (z > 5)
|
||||
|
Loading…
Reference in New Issue
Block a user