facebook twitter hatena line email

「Android/kotlin/基本」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
()
(同じ利用者による、間の1版が非表示)
行10: 行10:
 
==nullじゃない時の値==
 
==nullじゃない時の値==
 
  text1.setText(name ?: "hello");
 
  text1.setText(name ?: "hello");
 +
 +
==型==
 +
<pre>
 +
Int // 数字
 +
String // 文字
 +
Boolean // 真偽
 +
Array<String> // 文字配列
 +
Unit // voidみたいなもの、Unitは省略可能
 +
</pre>

2020年2月13日 (木) 17:47時点における版

null許可

var name: String = null // これだと入らない
var title: String? = null // ?をつけるとnullが許可される

読み込みのみ

valを使う

val description = "hoge"
description = "hoge2" // 許可されない

nullじゃない時の値

text1.setText(name ?: "hello");

Int // 数字
String // 文字
Boolean // 真偽
Array<String> // 文字配列
Unit // voidみたいなもの、Unitは省略可能