Skip to content

Commit 0d76f35

Browse files
author
Rafa Paradela
committed
Merge pull request scala-exercises#48 from hasumedic/by-name-parameter
Tiny typos in by-name-parameter
2 parents 47dbb03 + 82d24e0 commit 0d76f35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/json/bynameparameter.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"title": "ByName Parameter",
33
"modules": [
44
{
5-
"preparagraph": "`() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function and returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right.",
5+
"preparagraph": "`() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right.",
66
"code": "def calc(x: () => Int): Either[Throwable, Int] = {\n try {\n Right(x()) //An explicit call the the x function\n } catch {\n case b: Throwable => Left(b)\n }\n}\n\nval y = calc {() => //Having explicitly declaring that Unit is a parameter with ()\n 14 + 15\n}\n\ny should be (__)",
77
"solutions": [
88
"Right(29)"
99
],
1010
"postparagraph": ""
1111
},
1212
{
13-
"preparagraph": "A by-name parameter does the same thing as a previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in scala to create blocks.",
13+
"preparagraph": "A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in scala to create blocks.",
1414
"code": "def calc(x: => Int): Either[Throwable, Int] = { //x is a call by name parameter\n try {\n Right(x)\n } catch {\n case b: Throwable => Left(b)\n }\n}\n\nval y = calc { //This looks like a natural block\n println(\"Here we go!\") //Some superfluous call\n val z = List(1, 2, 3, 4) //Another superfluous call\n 49 + 20\n}\n\ny should be (__)",
1515
"solutions": [
1616
"Right(69)"
@@ -26,4 +26,4 @@
2626
"postparagraph": ""
2727
}
2828
]
29-
}
29+
}

0 commit comments

Comments
 (0)