随笔分类 -  Scala

摘要:Traits as Interfaces Let’s start with something familiar. A Scala trait can work exactly like a Java interface. For example: A subclass can provide an 阅读全文

posted @ 2016-09-17 17:36 chaseblack 阅读(160) 评论(0) 推荐(0)

摘要:Reading Lines To read all lines from a file, call the getLines method on a scala.io.Source object: The result is an iterator (see Chapter 13). You can 阅读全文

posted @ 2016-09-17 11:48 chaseblack 阅读(162) 评论(0) 推荐(0)

摘要:In this chapter, we only discuss the case in which a class inherits from another class. See Chapter 10 for inheriting traits —the Scala concept that g 阅读全文

posted @ 2016-09-16 17:05 chaseblack 阅读(249) 评论(0) 推荐(0)

摘要:Packages A package can be defined in multiple files. For example and Multiple packages can be in a single file. For example Note: There is no enforced 阅读全文

posted @ 2016-09-16 15:45 chaseblack 阅读(213) 评论(0) 推荐(0)

摘要:Use the object construct when you need a class with a single instance, or when you want to find a home for miscellaneous values or functions. Singleto 阅读全文

posted @ 2016-09-15 11:09 chaseblack 阅读(172) 评论(0) 推荐(0)

摘要:Simple Classes and Parameterless Methods In Scala, a class is not declared as public . A Scala source file can contain multiple classes, and all of th 阅读全文

posted @ 2016-04-20 00:15 chaseblack 阅读(184) 评论(0) 推荐(0)

摘要:Constructing a Map The value of "Alice" -> 10 is ("Alice", 10). You could have equally well defined the map as Accessing Map Values To check whether t 阅读全文

posted @ 2016-04-20 00:06 chaseblack 阅读(175) 评论(0) 推荐(0)

摘要:Fixed-Length Arrays Variable-Length Arrays: Array Buffers Traversing Arrays and Array Buffers The variable i goes from 0 to a.length - 1 . To visit ev 阅读全文

posted @ 2016-04-19 23:18 chaseblack 阅读(154) 评论(0) 推荐(0)

摘要:An expression has a value; a statement carries out an action. Conditional Expressions: IF-ELSE In Scala, an if / else has a value. For example: if (x 阅读全文

posted @ 2016-04-18 13:56 chaseblack 阅读(167) 评论(0) 推荐(0)

摘要:Interpreter Values and Variables You are encouraged to use a val unless you really need to change the contents. The type of a variable or function is 阅读全文

posted @ 2016-04-18 12:24 chaseblack 阅读(216) 评论(0) 推荐(0)

导航