0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Scala入門_型

Last updated at Posted at 2019-05-05

前回の環境構築編
https://qiita.com/zun_jun/items/abb74656362ef2138c41

Scalaの型

  • 今までJavaやPHPをメインにしてきましたが、Scalaでは以下の型が用意されている。
    • Any:すべての型のスーパークラス
    • AnyVal:値型のスーパータイプ
      • Byte:1バイト符号付き整数
      • Short:2バイト符号付き整数
      • Char:UnicodeのU+0000からU+FFFFまでを表す型
      • Int:4バイト符号付き整数
      • Long:8バイト符号付き整数
      • Float:4バイト浮動小数点数
      • Double:8バイト浮動小数点数
      • Boolean:真または偽の二値をとる型
      • Unit:何も返すものがないことを表す型(Javaだとvoid)
    • AnyRef:いわゆる参照型のスーパータイプ
      • StringやList、ユーザの定義したクラス
      • Null:すべての参照型のサブタイプ
    • Nothing:すべての方のサブタイプ

つらつら書きましたが、見慣れているのが
Byte、Short、Char、Int、Long、Float、Double、Boolean、Stringあたりかなと思います。
図?で書くと、
ーーーーー
Any
┣━━━━━━━━━━━━━━━━━━━━━━━━┓
AnyVal                                                                                AnyRef
┣━━┳━━┳━┳━┳━━┳━┳━━┳━━┓   ┣━┳━┓
Double Float Long Int Short Byte Unit Boolean Char String List MyClass
┣━━┻━━┻━┻━┻━━┻━┻━━┻━━┛   ┣━┻━┛
┃                         Null
┣━━━━━━━━━━━━━━━━━━━━━━━━┛
Nothing
ーーーーー
こんな感じらしいです。

終わり

見慣れないAny、AnyVal、Unit、Nothingが出てきました。
次回は、実際に手を動かしながら基本的なことをやっていけたらなと!
今学習に使わせていただいているのが、
■実践Scala入門
https://www.amazon.co.jp/%E5%AE%9F%E8%B7%B5Scala%E5%85%A5%E9%96%80-%E7%80%AC%E8%89%AF-%E5%92%8C%E5%BC%98/dp/4297101416/ref=sr_1_1?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&keywords=scala&qid=1557061726&s=gateway&sr=8-1
になります!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?