LoginSignup
0
0

More than 3 years have passed since last update.

immutableとmutableについて

Posted at

immutableとmutableについて

経緯

Flutterのcookbookでダウンロードボタンのエフェクトについて写経しているときに、出てきたimmutableがなんなのかわからなかったので。

意味

immutable:不可変
mutable:可変

imuutableにする目的

  • mutableだと変更されたくない値なども変更できるのでダメだ!
  • immutableにしてオブジェクト全体の参照ではなく、オブジェクトの参照の複製をすること。
  • そうすることで、値は変更されなくなって安全に値を使えるよ!
  • あと、メモリの節約と実行速度が速くなるよ。

まとめ

imuutableなクラスを作って、上手くオブジェクトを扱うようにしよう。

詳しく書いてくださっている記事様

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