Data classes - Kotlin Vocabulary

  Рет қаралды 27,273

Android Developers

Android Developers

Күн бұрын

Пікірлер: 23
@sayitsjose
@sayitsjose 3 жыл бұрын
Are data classes isomorphic to structs in Swift? @2:21 The jump from pointing out that varargs aren't supported in a data class to the quote from Andrey Breslav was a bit of a leap. Isn't it enough to say varargs are arrays which live in the heap? @4:47 What are synthetic methods? It sounds like copy and copy$default both share the same semantics.
@atanasdoychinov6491
@atanasdoychinov6491 4 жыл бұрын
The data class sounds so good to be used for creating of models, but without the inheritance its use is so limited...
@pradeepkumarreddykondreddy7048
@pradeepkumarreddykondreddy7048 4 жыл бұрын
Is destructuring allowed only for data classes ?
4 жыл бұрын
no. any class with the methods componentN (where N is a number >= 1) can be destructured. the number of variables you use in the left hand side of the assignment must match the number of componentN methods available in that class (e.g. val (x, y, z) = obj; only works if the class of obj has component1(), component2() and component3()). the data classes get those methods generated automatically for every parameter specified in its constructor, that's why it's easier with them. but it's allowed for any class [which matches the criteria above].
@siddharthchughs100
@siddharthchughs100 4 жыл бұрын
Hi , The videos is really good for good understanding for the data classes, but Would like to know , if we need to use the same class in the sqlite using kotlin , how to insert the data into the respective variables, as of when all the data items were kept val the sqlite was showing error and was suggesting convert the data item into the var and then was able to add all the data into the variables, therefore it was easy to show in the recyclerview using kotlin for the android application. In that case advice please, Thanks
@GemiDroid
@GemiDroid 4 жыл бұрын
So great video, but I am wondering what's the benefits of making data class final?
@kolenyov
@kolenyov 4 жыл бұрын
discuss.kotlinlang.org/t/data-class-inheritance/4107/2 Inheriting a data class from another data class is not allowed because there is no way to make compiler-generated data class methods work consistently and intuitively in case of inheritance.
@GemiDroid
@GemiDroid 4 жыл бұрын
@@kolenyov Thanks I got it 👍
@MaisUmSomente
@MaisUmSomente 2 жыл бұрын
windows Ctrl +Shift+A show Kotlin Bytecode action. 02:54
@willculpepper9637
@willculpepper9637 Жыл бұрын
All aboard for NotNullNovember
@mindfulnessrock
@mindfulnessrock Жыл бұрын
You haven't really gotten into its restriction that much, or even like real life scenario of where they fit the best, instead of of regular classes. Great anatomical explanation still!
@samuelrake7832
@samuelrake7832 4 жыл бұрын
Whenever i remember the way data classes made me write less code when creating recyclerviews compared to java.. i sigh in relief
@RahulPahuja1991
@RahulPahuja1991 4 жыл бұрын
do u mean we cannot have a parent child relationship for a data class?
@kosmozaut
@kosmozaut 4 жыл бұрын
Correct and it kinda sucks
@amir32806
@amir32806 4 жыл бұрын
For some reason it compiles as a final class in Java
@farazahmed7
@farazahmed7 2 жыл бұрын
Inheritance should never be the first option. Kotlin strictly follows Composition over inheritance as it should be. Do read more about this and you will understand why Kotlin classes are final by default.
@febaisi1
@febaisi1 4 жыл бұрын
I am still not exactly sure why Data Classes can't inherit from another Data class. ;/
@AmitJayant
@AmitJayant 2 жыл бұрын
The weirdest syntax in all of Programming languages
@xpopcornx1747
@xpopcornx1747 4 жыл бұрын
again?
@gabormiklay9209
@gabormiklay9209 4 жыл бұрын
I wonder what breed of doggo Florina has... 🤔
@rayanfernandes2631
@rayanfernandes2631 4 жыл бұрын
Why make data class if we can make class with data attributes
@ytechnology
@ytechnology 4 жыл бұрын
Not an expert here, but I've used data classes to hold return values from functions that return multiple values.
@kolenyov
@kolenyov 4 жыл бұрын
Benefits of the autogenerated methods like components() for destructive declaration and copy() for an immutability.
Breaking down destructuring declarations - Kotlin Vocabulary
3:53
Android Developers
Рет қаралды 12 М.
Suspend functions - Kotlin Vocabulary
9:03
Android Developers
Рет қаралды 51 М.
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
Object - Kotlin Vocabulary
7:53
Android Developers
Рет қаралды 32 М.
Delegating delegates - Kotlin Vocabulary
8:44
Android Developers
Рет қаралды 26 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
Every Minute One Person Is Eliminated
34:46
MrBeast
Рет қаралды 29 МЛН
Going with the flow - Kotlin Vocabulary
13:38
Android Developers
Рет қаралды 64 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 498 М.
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН