Skip to content

Instantly share code, notes, and snippets.

@omochi
Last active May 10, 2016 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omochi/14cfb2a8059e11101e96673619b950c9 to your computer and use it in GitHub Desktop.
Save omochi/14cfb2a8059e11101e96673619b950c9 to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
// valは定数(再代入禁止)
val a = 3
// if文が三項演算子みたいに機能するので定数定義の右辺値にできる。
// さらにifとelseの本文両方からの型推論が効いて、bの型はStringになっている
val b = if (a > 1) {
"big"
} else {
"small"
}
print(b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment