is NameDelegate object created for each property or there is only one object for every property. Because if it create objects for each property then it may be inefficient.
Hi belal... Can you please make just one more video on reflection in kotlin and add it to this list,,,, I need to fully understand Reflection,, you are amazing teacher thank you
Hey Belal. How is this delegation any different than creating a common private method to avoid redundant code? I mean what is the significance of delegation over creating a common method in this case?
Hi Have one doubt I try to re assign some different value (which is below range of 5) in student's firstName and lastName but it cannot assign again In output, it shows old value
cant we just create a function that does the validation and used that validation in setter and getter like this class Student { var firstName: String? = null set(value) { if (isValid(value)) field = value?.trim()?.toUpperCase() } var secondName: String? = null set(value) { if (isValid(value)) field = value?.trim()?.toUpperCase() } private fun isValid(data: String?) = data != null && data.length > 5 }
Kind of confusing syntax but explained well. Programming is getting crazy over the decades.
Finally, I understand delegation. THANKS ALOT.
Beautifully explained, thanks!
Thanks ❤️
Excellent example, regards from Caracas, Venezuela
Amazing explanation. I never thought how easy it is.
Excellent! I finally get the idea and I love this feature ;-D
Best explanation, thanks a lot
We can also use "data class" for printing the class :)
you have explained very well
is NameDelegate object created for each property or there is only one object for every property. Because if it create objects for each property then it may be inefficient.
Thanks a lot, such a clear explanation
Hi belal... Can you please make just one more video on reflection in kotlin and add it to this list,,,, I need to fully understand Reflection,, you are amazing teacher thank you
Hey Belal. How is this delegation any different than creating a common private method to avoid redundant code? I mean what is the significance of delegation over creating a common method in this case?
Can you submit your version of the code?
Can't we achieve the same with extension functions ?
you explained this very beautifully
Thank you Sir
confusing with operator fun , by the way great info
Custom implementation of the 'setValue' operator using operator overloading.
Hi
Have one doubt
I try to re assign some different value (which is below range of 5) in student's firstName and lastName but it cannot assign again
In output, it shows old value
How I want check varriavble value is even only using a single variable not a class
Loved it!
Okay I understand delegation, but what would be called as delegate in the above example?
It is delegation in the sense that you are sending validation responsibility to another class that actually validating the first and last name.
thanks man!
I didn't understand the property thing please someone explain
Viradar you threw Kproperty and operator keyword without explaining, I finding it difficult to follow this way
cant we just create a function that does the validation and used that validation in setter and getter like this
class Student {
var firstName: String? = null
set(value) {
if (isValid(value))
field = value?.trim()?.toUpperCase()
}
var secondName: String? = null
set(value) {
if (isValid(value))
field = value?.trim()?.toUpperCase()
}
private fun isValid(data: String?) = data != null && data.length > 5
}
Still the delegation is more concise as you can clearly see.
Hi sir , how to crack technical round android interviews 😢
Suppose if they ask either API calling or something like that?? I am new...
you can say i am fresher and learning these topics or better to learn these topics in this channel.
@@ss-xn5rw thank you...😊😊
This can be done easily by using Extension functions.
Good content
a