Created
July 29, 2013 06:56
-
-
Save f81/6102548 to your computer and use it in GitHub Desktop.
第6章:Scalaのプリミティブ型を語る ref: http://qiita.com/f81@github/items/c43803f4a8da94615c9c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scalac Literal.scala | |
$ scala Literal | |
dec:24 | |
hex:36 | |
prog:36 | |
big:1.2 | |
bigger:120.0 | |
biggerStill:1.2E45 | |
little:1.2 | |
a:あ | |
name:田沢 慎一郎 | |
sentence:Test test | |
test "test" | |
bool:true | |
s:synbolA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Literal { | |
def main(args: Array[String]){ | |
// 整数リテラル | |
// 10進数 | |
val dec = 24 | |
println("dec:" + dec) | |
// 16進数 | |
val hex = 0x24 | |
println("hex:" + hex) | |
// Long | |
val prog = 35L | |
println("prog:" + hex) | |
// 浮動小数点数リテラル | |
val big = 1.2 | |
println("big:" + big) | |
val bigger = 1.2e2 | |
println("bigger:" + bigger) | |
val biggerStill = 1.2e45 | |
println("biggerStill:" + biggerStill) | |
val little = 1.2f | |
println("little:" + little) | |
// 文字リテラル | |
val a = 'あ' | |
println("a:" + a) | |
// 文字列リテラル | |
val name = "田沢 慎一郎" | |
println("name:" + name) | |
val sentence = """|Test test | |
|test "test"""".stripMargin | |
println("sentence:" + sentence) | |
// 真偽値リテラル | |
val bool = true | |
println("bool:" + bool) | |
// シンボルリテラル | |
val s = 'synbolA | |
println("s:" + s.name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment