官术网_书友最值得收藏!

Deep Dive into Functions

Scala combines both object-oriented and functional programming paradigms. In particular, functions are a first-class language concept. They can be defined in a variety of ways, assigned to variables, passed as parameters, and stored in data structures. Scala gives a lot of flexibility with regard to how these actions can be performed.

We'll start this chapter by looking in detail at different flavors of defining a function. We'll then go on and apply the knowledge about types from the previous chapter to make our functions polymorphic and higher order. We'll study recursion, tail recursion, and trampolining as important aspects of functional programming for the JVM. Finally, we'll evaluate peculiarities related to the fact that functions in Scala are implemented in an object-oriented way.

The following topics will be covered in this chapter:

  • Ways to define a function
  • Polymorphic functions
  • Higher order functions
  • Recursion
  • Trampolining
  • Object-oriented aspects of functions
主站蜘蛛池模板: 青铜峡市| 临江市| 英超| 礼泉县| 舒兰市| 金坛市| 旌德县| 长乐市| 宣武区| 巴楚县| 衡东县| 革吉县| 巫溪县| 宾川县| 孟州市| 榆社县| 岢岚县| 宁晋县| 昌都县| 贺州市| 上饶县| 新源县| 惠安县| 桃园市| 牡丹江市| 神农架林区| 遵义市| 正镶白旗| 元谋县| 博野县| 桐乡市| 德格县| 方山县| 邵东县| 赤壁市| 申扎县| 府谷县| 手机| 长治市| 祁东县| 金塔县|