Around 11:00, I think switch(Shape shape) should be just switch(shape), with the variable previously declared... I'm enjoying the video enough to be trying examples with the Early Access release and old-school command-line javac and java commands!
Hi Jose, A great video! You are a great teacher. I love your courses on Pluralsight. Thank you and enjoy your Java coffee ☕ Lot’s of greetings, Dennis 🇳🇱
Is it too difficult for the language to infer the type of o based on the assertion in the if statement so inside the if o is an string without the need of a new variable?
Would it be a good idea to be able to have more than one variadic parameter, such that one takes the odd elements and the other takes the even elements? Useful for Map.of
17:55 - `for` loop throwing exception if an `Iterable` is empty when pattern matching is used is just terrible, insane even, and is absolutely counter intuitive.
@@alessioantinoro5713 Oh, thanks! I re-watched, and I still hear "especially if you have NO elements in this list" if I don't make effort to really listen and hear "NULL elements", now that I know what the phrase actually is. Of course, with `null` elements that behavior totally makes sense.
In for(Points(double x, double y) : pts) instead of having to mention double data type every time it is better to provide a generic type so as to avoid exception while iterating. *Generic types can be bounded* One more thing is that there could be a third point for z-axis(double z) so there must be an overloaded constructor. So it is much better to have a vararg parameter. I don't how this will affect performance and memory. I haven't read the docs properly so it's just an idea from this video.
8:39 is really weird. Everyone that has used curly brace languages knows variables only exist in the { } they're declared in. Sure, it's not hard to wrap your head around it, but maybe it could have been done in another way ...
Pattern matching is required for functional programming. But this is anti-pattern in OOP (example with Shape is not in OOP style) And on practice people will use it for creating ugly procedural code
This is niche. In a case where you are already using runtime polymorphism and you want to add an ancilliary feature that would violate other principles, switch with lambda can provide an easier and more readable solution. Nicholai Parlog has a TH-cam where he codes suitable examples.
Feel like I could watch this gentleman talk about Java all day long. This is my third video. Love the content and delivery!
Glad you enjoyed it!
Really appreciate these videos and the format of them! Thanks!
Glad you like them!
It gives me joy listening and learning from you. Thank you sir!
So nice of you
I like these kind of videos. Seems to me like finding hidden pearls to be used.
I'm really looking forward to Java 21
Man your pfp are the dudes from my work "Wait, is there any Java version after 8?"
@@gabrielfreitas4270 I am running with this pfp for a decade now. And I've seen fireships video as well.
Around 11:00, I think switch(Shape shape) should be just switch(shape), with the variable previously declared... I'm enjoying the video enough to be trying examples with the Early Access release and old-school command-line javac and java commands!
that was also a question i see at this point - whats the right feature?
Hi Jose, A great video! You are a great teacher. I love your courses on Pluralsight. Thank you and enjoy your Java coffee ☕
Lot’s of greetings, Dennis 🇳🇱
Nice and clear explanations.
All I need now is a java cup ☕
Nicely delivered, clear and simple.
9:00 this is great. But the syntax is unnatural. I wonder if there is a syntactic better way to expose s to the rest of the method that is more clear.
Is it too difficult for the language to infer the type of o based on the assertion in the if statement so inside the if o is an string without the need of a new variable?
Cool, do you know what also is cool? The Java coffee cup you got! Would love to have one on my desk and flex on my colleagues : )
😄Thanks!
It would be great if record patterns could be used on assignments like this:
Point(int x, int y) = foo.getPoint();
That's part of the future plans. Maybe it will come?
Thanks for the awesome video
Thanks!
Nice! Next steps: pattern matching in function and lambda arguments
Nice do you have a full course on Java core programming from A to Z thanks.
Would it be a good idea to be able to have more than one variadic parameter, such that one takes the odd elements and the other takes the even elements? Useful for Map.of
Will there be boolean only patterns when you've got a single type?
E.g.
List is Empty -> ...
default -> ...
just check with `if` condition, I think there is no need for that in switch
@@fertiz_ You can use: case List l when l.isEmpty() -> { } instead of the if.
Thank you so much for this video!
17:55 - `for` loop throwing exception if an `Iterable` is empty when pattern matching is used is just terrible, insane even, and is absolutely counter intuitive.
Not when it is empty, when it contains null values
I'm not so sure that putting null values in a collection is a such great idea 😄
@@alessioantinoro5713 Oh, thanks! I re-watched, and I still hear "especially if you have NO elements in this list" if I don't make effort to really listen and hear "NULL elements", now that I know what the phrase actually is. Of course, with `null` elements that behavior totally makes sense.
@@JosePaumard I misheard the phrase and confused "NULL elements" with "NO elements".
@@stIncMale No wonders! It happens
Super Java evolution
Why not release switch pattern directly?
AFAIK, preview feature should be completed in 12 months
It's in preview to receive feedback, and the development time depends entirely on the feature...
Sometimes but not always. Some may even be removed without becoming final features. It happened with Raw String. It all depends on the feedback.
Adding features to java is making me an old man, how slowly it is going on.
In for(Points(double x, double y) : pts) instead of having to mention double data type every time it is better to provide a generic type so as to avoid exception while iterating. *Generic types can be bounded*
One more thing is that there could be a third point for z-axis(double z) so there must be an overloaded constructor. So it is much better to have a vararg parameter. I don't how this will affect performance and memory. I haven't read the docs properly so it's just an idea from this video.
You can use _for(Points(var x, var y) : pts)_ instead of mentioning double twice
8:39 is really weird. Everyone that has used curly brace languages knows variables only exist in the { } they're declared in.
Sure, it's not hard to wrap your head around it, but maybe it could have been done in another way ...
Fortunately we have Kotlin. In Kotlin code is more expressive.
Pattern matching is required for functional programming. But this is anti-pattern in OOP (example with Shape is not in OOP style)
And on practice people will use it for creating ugly procedural code
This is niche. In a case where you are already using runtime polymorphism and you want to add an ancilliary feature that would violate other principles, switch with lambda can provide an easier and more readable solution. Nicholai Parlog has a TH-cam where he codes suitable examples.
Java is looking very LISP with those Parentheses...
Happy to see that java is copying useful features from other languages, but worried it will ruin existing ones