d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Lambda Expressions
Add Reply New Topic New Poll
Member
Posts: 31,292
Joined: Mar 25 2009
Gold: 0.00
Dec 25 2019 11:38pm
Any Java developers could explain Lambda expressions for me? I've watched multiple videos and i'm still not understanding it... Thanks
Member
Posts: 2,619
Joined: May 21 2004
Gold: 21,934.00
Dec 25 2019 11:56pm
Uhh we gotta start somewhere. What are you having trouble understanding?

In the simplest form, its a list of parameters that get passed to an inline function declaration. Can you give me a context in which youd like to use it? That might help explain things.

This post was edited by frixionburne on Dec 25 2019 11:57pm
Member
Posts: 12,703
Joined: May 17 2013
Gold: 12,935.00
Dec 26 2019 08:57am
Code
() -> System.out.println("Zero parameter lambda");
(int a) -> System.out.println(a); // One parameter lambda
(int a, int b) -> System.out.println(a + b); // Two parameter lambda


this is basically equivalent to creating a function declaration, it's just shorthand.
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Dec 27 2019 12:14pm
I would like to add that personally I don’t think you should use lambda expressions in Java. Java is not a functional programming language and it is my opinion that if you’re writing java code you should stick to the OOP paradigm.
Member
Posts: 12,703
Joined: May 17 2013
Gold: 12,935.00
Dec 27 2019 01:47pm
Quote (Mastersam93 @ 27 Dec 2019 19:14)
I would like to add that personally I don’t think you should use lambda expressions in Java. Java is not a functional programming language and it is my opinion that if you’re writing java code you should stick to the OOP paradigm.


java is pretty shit, but it can certainly benefit from adopting features inspired by functional programming languages.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll