Kotlin Newbie to Pro - ANONYMOUS CLASSES - Part 26

  Рет қаралды 16,618

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 24
@dmgujjar6044
@dmgujjar6044 2 жыл бұрын
This is the best programming tutorial of my career since 2014!!
@srr1424
@srr1424 2 жыл бұрын
Thank u philipp for the best and awesome series. I am one of your subscriber.
@mariuszmilewski2084
@mariuszmilewski2084 2 жыл бұрын
I'm not a programmer, but I like to play with programming from time to time. Kotlin this time. So far your lessons are the best I've found.👍👍 I grew up on functions and still can't understand what classes give :), but maybe someday...
@lukalukovic5082
@lukalukovic5082 Жыл бұрын
Philipp is really good, because of him I landed a job as an android developer at only 18 years old. I recommend you stick to him if you want to become an android developer, and good luck in your future endeavours
@Luffy_2804
@Luffy_2804 Жыл бұрын
@@lukalukovic5082 how much time did it take to learn android dev?
@userglls
@userglls 10 ай бұрын
@@lukalukovic5082 I've been learnin kotlin from that playlist. I'll become an android dev in future (I'm 15)
@s.predator536
@s.predator536 Жыл бұрын
Wow this is series is so good🔥
@ekkawutemeelugsana7068
@ekkawutemeelugsana7068 3 жыл бұрын
Hi Philipp Lackner, I have a question about this Anonymous classes because with this example I would prefer to create a new class that Inherit from Shape. for S.O.L.I.D Principle, So I don't have to touch the Shape class anymore. class Parallelogram(private val a: Double, private val b: Double, private val height : Double) : Shape("Parallelogram"){ override val area: Double = a * height override val perimeter: Double = 2 * a + 2 * b fun isRectangle() = height == b } Could you give me another and more clear example about when to use Anonymous classes and why?
@sumeet21587
@sumeet21587 3 күн бұрын
You are not touching the Shape class and modifying it. It is just creating an instance of an anonymous class that inherits the Shape class with the use of an object keyword. The use case would be in a code base where you want the Shape class concrete implementation to be in one place. I hope I was able to explain!
@mohammednashat6707
@mohammednashat6707 2 жыл бұрын
احسن واحد ف الكون 😉
@thomasgeorge4578
@thomasgeorge4578 4 жыл бұрын
These videos are really good 🔥🔥
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks! :)
@numeshdilusha8106
@numeshdilusha8106 Жыл бұрын
Pill can you mention the real life use case as well it would be grate for new students !
@pikaboyny
@pikaboyny 4 жыл бұрын
How common would you say Anonymous classes are used in implementations of Kotlin like Android Development? It looks like it's very useful but I feel like it's not good coding conventions? I don't know, I'm transitioning from Java so it's weird to have so much more flexibility in a language like Kotlin lol
@PhilippLackner
@PhilippLackner 4 жыл бұрын
It's very commonly used. You also have it in Java (for example if you do something like new Interface{...})
@kevinsolanki6232
@kevinsolanki6232 4 жыл бұрын
This is strange.. really strange..I didn't get it... So as you said first...When we need implementation of class with slight modification but we don't want to create completely new class for and this case we can create anonymous class. So..which class is anonymous !?...Okay we got only one class here..so does that mean Shape class is anonymous class !?..and where implemented modification !?
@PhilippLackner
@PhilippLackner 4 жыл бұрын
The anonymous class is what you create with object : Shape
@kevinsolanki6232
@kevinsolanki6232 4 жыл бұрын
I completely ignored object keyword🤦🤦🤦. Now I know why there was quiz question on website that whether "object" keyword we use in anonymous class is different than the "object" keyword we use in companion object. So, now we can do whatever we want in this object: Shape class because it is anonymous. Thanks bro🙏✨🌈
@asimlatif360
@asimlatif360 3 жыл бұрын
Great Explanation!
@jayjan_py
@jayjan_py 4 ай бұрын
Me learning this concept and knowing I am never going to use this in real life. 😭😭
@zepra2133
@zepra2133 2 жыл бұрын
is other language have anonymus class like this?
@filip_g
@filip_g 3 жыл бұрын
AMAZING!
@AniobiStanley
@AniobiStanley Жыл бұрын
val base1 = 4.0 val base2 = 6.0 val side1 = 3.0 val side2 = 5.0 val height = 2.0 val trapezium = object : Shape("Trapezium", base2, base1, side2, side1){ init { println("Created a $name with sides: $side1, $side2, $base1, $base2. Area of the $name is ${area()}. Perimeter of the $name is ${perimeter()}.") } override fun area(): Double = 0.5 * height * (base2 + base1) override fun perimeter(): Double = base1 + base2 + side1 + side2 fun isRectangle() = side2 == side1 } println("Is the ${trapezium.name} a rectangle? - ${trapezium.isRectangle()}.")
@jonievillejo6746
@jonievillejo6746 Жыл бұрын
// :) I hope I understand well that you meant to say was a Trapezoid. Just created the main here. fun main() { val base1 = 3.0 val base2 = 11.0 val leg1 = 8.0 val leg2 = 10.0 val height = 7.0 val trapezoid = object : ShapeAssignment26("Trapeze", base1, base2, leg1, leg2, height) { init { println("Trapeze created with base1 = $base1, base2 = $base2, leg1 = $leg1, leg2 = $leg2 and height = $height") println("The area is ${area()}") println("The perimeter is ${perimeter()}") } override fun area(): Double { return height * ((base1 + base2) / 2) } override fun perimeter(): Double { return (base1 + base2 + leg1 + leg2) } fun isRectangle(): Boolean = ((leg1 == height) && (leg2 == height)) } println("Is the Trapeze a rectangle? ${trapezoid.isRectangle()}") }
Kotlin Newbie to Pro - EXCEPTIONS - Part 27
14:26
Philipp Lackner
Рет қаралды 13 М.
Kotlin Newbie to Pro - GENERICS - Part 29
19:41
Philipp Lackner
Рет қаралды 33 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Kotlin Object Expression and Anonymous Inner Class
9:04
Simplified Coding
Рет қаралды 7 М.
Kotlin Newbie To Pro - OBJECTS AND COMPANION OBJECTS - Part 25
12:42
Philipp Lackner
Рет қаралды 23 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 140 М.
Kotlin Newbie to Pro - INHERITANCE - Part 21
15:07
Philipp Lackner
Рет қаралды 19 М.
Let, Also, Apply, Run, With - Kotlin Scope Functions
11:44
Philipp Lackner
Рет қаралды 100 М.
Kotlin Newbie to Pro - LAMBDA FUNCTIONS - Part 28
16:29
Philipp Lackner
Рет қаралды 35 М.
Kotlin Newbie To Pro - VARARG, DEFAULT AND NAMED PARAMETERS -  Part 18
15:11
Kotlin Newbie to Pro - CONSTRUCTOR AND FUNCTION OVERLOADING - Part 24
16:00
Kotlin Delegation Tutorial with Example
6:54
Simplified Coding
Рет қаралды 20 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН