Coder Social home page Coder Social logo

Comments (7)

ttokutake avatar ttokutake commented on August 11, 2024 1

Javaのライブラリーの呼び出しするときとかで使いたいときあるかなと思ってたんですが、
そもそもプラットフォーム型という特別な扱いをするから違いましたね。
あとはKotlin製のライブラリーや何かしらのフレームワークの都合でnullable typeだけど自分の使い方ではnon-null typeでいいみたいな時に使いたいかもしれないですが、
頻発するケースがないのであればそんなに考慮しなくて良い気がしてます。
なんで方針として"基本使うな"という案で良いと思います。

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

ちなみに、「強制アンラップ」「オプショナル」というワードは Kotlin の公式リファレンスには出てこない。Swift では聞くような気がするので Swift の用語なのかもしれない。
!! オペレータや ? を使うことで Kotlin でも同じ意味の処理をやっているのかもしれないが、公式な用語でないということで、基本的にはこれらの単語は使わずに解説を行うように考えているところ。

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

!! に関する公式リファレンスはおそらく以下のページ。
有効な使いどころについては触れられてない。「ぬるぽが好きなら使え」とのこと。
https://kotlinlang.org/docs/reference/null-safety.html

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

!! の呼び方は、"non-null assertion operator" で良さそう。
ぐぐるならこれで。

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

https://medium.com/@igorwojda/kotlin-combating-non-null-assertions-5282d7b97205

Each time you use non-null assertion you are saying to Kotlin compiler “I am 100% sure that this will not be null” and the reality is that in most of cases there are better and safer ways solutions to achieve the same result.

100%ヌルじゃないことが分かってるときに使えばいいけど、そういうときはたいていもっといい書き方できるよね!

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

基本的に使わないということを書いておこうと思います。

from kotlin_intro.

pankona avatar pankona commented on August 11, 2024

@ttokutake
コメントありがとうございます。
プラットフォーム型については話せば長くなるので今回の資料には乗せていないですが、やっていくうちに考慮しないといけないケースは出てくるはずなので、まったく言及しないのも微妙ですね…。どっかで盛り込むかどうかは別途検討します。

基本方針についての確認ありがとうございます。
その線で行きます!

from kotlin_intro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.