Skip to content

Commit

Permalink
Add examples taken from reference page (#18066)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kordyjan authored Jun 27, 2023
2 parents 8205a5b + f1a17a5 commit 8184fa8
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/pos/fewer-braces.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,57 @@ def Test =
x + 1
println(y)


true // Should not count as the call true()
()

// Setup
def times(x: Int)(f: => Unit): Unit =
(0 to x).foreach(_ => f)
val credentials = Seq()
object Path {def userHome = File}
object File {def exists = true; def /(s: String) = this}
def Credentials(f: File.type) = f
val xs = List(1,2,3)
def f(x: Int, g: Int => Int) = g(x)
val x = 4

// Copied from docs/_docs/reference/other-new-features/indentation.md

times(10):
println("ah")
println("ha")

credentials `++`:
val file = Path.userHome / ".credentials"
if file.exists
then Seq(Credentials(file))
else Seq()

xs.map:
x =>
val y = x - 1
y * y

xs.foldLeft(0): (x, y) =>
x + y

{
val x = 4
f(x: Int, y =>
x * (
y + 1
) +
(x +
x)
)
}

x match
case 1 => print("I")
case 2 => print("II")
case 3 => print("III")
case 4 => print("IV")
case 5 => print("V")

println(".")

0 comments on commit 8184fa8

Please sign in to comment.