Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few text tweaks #68

Merged
merged 3 commits into from
Dec 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/scala/stdlib/Classes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ object Classes extends FlatSpec with Matchers with org.scalaexercises.definition
* }
* }}}
*
* The program defines an executable application `Classes` in form of a top-level singleton object with a `main` method. The `main` method creates a new `Point` and stores it in value `pt`.
* The program defines an executable application `Classes` in the form of a top-level singleton object with a `main` method. The `main` method creates a new `Point` and stores it in value `pt`.
*
* This also demonstrates the use of a value parameters in ClassWithValParameter(val name: String), which automatically creates an internal property (val name: String) in the class.
* This also demonstrates the use of value parameters in ClassWithValParameter(val name: String), which automatically creates an internal property (val name: String) in the class.
*
*/
def classWithValParameterClasses(res0: String) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/stdlib/HigherOrderFunctions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis

/** Meet lambda. Scala provides a relatively lightweight syntax for defining anonymous functions. Anonymous functions in source code are called function literals and at run time, function literals are instantiated into objects called function values.
*
* Scala supports first-class functions, which means you can express functions in function literal syntax, i.e.,` (x: Int) => x + 1`, and that functions can be represented by objects, which are called function values.
* Scala supports first-class functions, which means you can express functions in function literal syntax, i.e.,` (x: Int) => x + 1`, and those functions can be represented by objects, which are called function values.
*/
def meetLambdaHigherOrderFunctions(res0: Int, res1: Int, res2: Int, res3: Int, res4: Int, res5: Int) {
def lambda = { x: Int ⇒ x + 1 }
Expand Down Expand Up @@ -68,7 +68,7 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis
result2 should be(res1)
}

/** We can take that closure and throw into a method and it will still hold the environment
/** We can take that closure and throw it into a method and it will still hold the environment
*/
def holdEnvironmentHigherOrderFunctions(res0: Int, res1: Int) {
def summation(x: Int, y: Int ⇒ Int) = y(x)
Expand Down Expand Up @@ -113,15 +113,15 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis
fiveAdder(5) should be(res2)
}

/** `isInstanceOf` is the same as `instanceof` in java, but in this case the parameter types can be *blanked out* using existential types with a single underline, since parameter type are unknown at runtime.
/** `isInstanceOf` is the same as `instanceof` in java, but in this case the parameter types can be *blanked out* using existential types with a single underline, since parameter types are unknown at runtime.
*/
def isInstanceOfMethodHigherOrderFunctions(res0: Boolean) {
def addWithSyntaxSugar(x: Int) = (y: Int) ⇒ x + y

addWithSyntaxSugar(1).isInstanceOf[Function1[_, _]] should be(res0)
}

/** Function taking another function as parameter. Helps in composing functions.
/** Function taking another function as a parameter. Helps in composing functions.
*
* Hint: a map method applies the function to each element of a list
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/stdlib/Options.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object Options extends FlatSpec with Matchers with org.scalaexercises.definition
/** An alternative for pattern matching is performing collection style operations.
* This is possible because an option could be looked at as a collection with either one or zero elements.
*
* One of these operations is `map`. this operation allows to map the inner value to a different type while preserving the option
* One of these operations is `map`. This operation allows us to map the inner value to a different type while preserving the option
*/
def mapOptions(res0: Option[Double], res1: Option[Double]) {
val number: Option[Int] = Some(3)
Expand All @@ -88,7 +88,7 @@ object Options extends FlatSpec with Matchers with org.scalaexercises.definition
/** Note that the type of result1 is now Option[Double], thanks to the scala type inference. */
}

/** Another operation is `fold`. this operation will extract the value from the option, or provide a default if the value is `None`
/** Another operation is `fold`. This operation will extract the value from the option, or provide a default if the value is `None`
*/
def foldOptions(res0: Int, res1: Int) {
val number: Option[Int] = Some(3)
Expand Down