scala基本数据类型学习

  Scala does not support octal literals; integer literals that start with a 0, such as 031, do not compile.

  If an integer literal ends in an L or l, it is a Long; otherwise it is an Int.

  If a floating-point literal ends in an F or f, it is a Float; otherwise it is a Double. Optionally, a Double floating-point literal can end in D or d.

  Character literals are composed of any Unicode character between single quotes.

  In addition to providing an explicit character between the single quotes, you can identify a character using its Unicode code point. To do so, write \u followed by

four hex digits with the code point, like this:

  scala> val d = '\u0041'

  d: Char = A

  scala> val f = '\u0044'

  f: Char = D  

  This identifier is treated as identical to BAD, the result of expanding the two Unicode characters in the code above. In general, it is a bad idea to name

identifiers like this because it is hard to read. Rather, this syntax is intended to allow Scala source files that include non-ASCII Unicode characters to

be represented in ASCII.

  A string literal is composed of characters surrounded by double quotes.

  You start and end a raw string with three double quotation marks in a row ("""). The interior of a raw string may contain any characters whatsoever, including

newlines, quotation marks, and special characters, except of course three quotes in a row.

发布了143 篇原创文章 · 获赞 31 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/u25th_engineer/article/details/100167351
今日推荐