concept parameter in category scala

appears as: parameters, parameter, parameters, parameter
Get Programming with Scala

This is an excerpt from Manning's book Get Programming with Scala.

Functional Programming languages base their entire structure on functions. Functions play a big part in Scala as its “first-class citizens”. In lesson 6, you’ll learn their basics and how to define them. In unit 4, you’ll discover functional purity and its several advantages and to how you can use functions as parameters or return values: you refer to them as higher order functions. They allow you to create powerful abstractions that simplify and remove duplication of your code in a way that is usually not so easily achievable in an object-oriented approach. Listing 1.5 shows an example of a function that takes another function as its parameter, and that returns a new function.

scala> def sayHello(n: String): String = s"hi $n!"
sayHello: (n: String)String
 
scala> def sayHello(n: String): Int = s"hi $n!"
<console>:10: error: type mismatch;
 found   : String
 required: Int
       def sayHello(n: String): Int = s"hi $n!"
                                   ^

In Scala functions are first class citizens: you can use them as parameters or return them as the result of some computation. “Higher order functions” are functions that accept other functions as parameters, or that return functions, or both. Their use allows you to create powerful abstractions that reduce code duplication and increase the reusability of your programs. In the capstone, you’ll use higher order functions to extract information on the winner of the game “Paper, Rock, Scissors, Lizard, Spock!”.

Play for Scala: Covers Play 2

This is an excerpt from Manning's book Play for Scala: Covers Play 2.

Scala makes it possible for web application code to be more type-safe. URL routing and template files are parsed using Scala, with Scala types for parameters.

The page title and the HTML block are both passed as parameters to main, which is another template: the layout template.

2.2.4. Adding a parameter to a controller action

Because our new action needs to know which product to show, we’ll give it a parameter whose value will be the requested product’s EAN code. The action will use the EAN to find the right product and have it rendered, or return a 404 error if no product with that EAN was found. Listing 2.20 shows what it looks like.