- Learning Scala Programming
- Vikash Sharma
- 187字
- 2021-06-30 19:07:45
Super smart syntax
You are going to write succinct code with Scala. There are a lot of examples we can look at to see Scala's syntax conciseness. Let's take an example from Scala's rich collections and create a Map:
val words = Map ("Wisdom" -> "state of being wise")
println(words("Wisdom"))
> state of being wise
The preceding code is creating a map of words and their meaning. Only Map ("Wisdom" -> "state of being wise") is the amount of code we have to write to make it possible. No need to add semicolons. We did not even mention the type of our value and the Scala compiler was able to infer it. Type inference is a characteristic of this language. Because of Type inference, a lot of times we omit type declaration and use a value directly. This way, using only a minimal set of words/tokens you can express the logic to implement them. Constructs like case classes and pattern matching take away the extra effort one might have to make and makes writing code joyful. It also helps you reduce written code by a good margin.
- 多媒體CAI課件設計與制作導論(第二版)
- PHP 7底層設計與源碼實現(xiàn)
- Full-Stack React Projects
- 鋒利的SQL(第2版)
- 小學生C++創(chuàng)意編程(視頻教學版)
- 圖數(shù)據(jù)庫實戰(zhàn)
- C# Multithreaded and Parallel Programming
- Qt5 C++ GUI Programming Cookbook
- 現(xiàn)代C:概念剖析和編程實踐
- Flink入門與實戰(zhàn)
- 軟硬件綜合系統(tǒng)軟件需求建模及可靠性綜合試驗、分析、評價技術
- Flask開發(fā)Web搜索引擎入門與實戰(zhàn)
- Mastering Machine Learning with scikit-learn
- Scratch少兒編程高手的7個好習慣
- MySQL數(shù)據(jù)庫應用技術及實戰(zhàn)