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

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
主站蜘蛛池模板: 谷城县| 宜丰县| 托克逊县| 图木舒克市| 仙桃市| 全州县| 中西区| 名山县| 广汉市| 萍乡市| 海宁市| 芜湖市| 和田县| 嵩明县| 荆门市| 万全县| 淳化县| 台中县| 沐川县| 五原县| 吉首市| 临安市| 鹤山市| 石渠县| 漾濞| 衡东县| 敦煌市| 临漳县| 沧源| 天峻县| 清徐县| 尤溪县| 巴彦淖尔市| 固始县| 旬邑县| 富平县| 遵义市| 岳阳县| 平度市| 兴业县| 塘沽区|