I’m back. Sorry in advance.
I’m still lost on the lambdas, but I am trying to figure out how to contribute here while not being too much of “that guy.”
So, you can skip this paragraph, but for context, I’m the widget guy. I’m low-code or die. Now, that still means some code, of course, and that’s why I am here infecting this thread. When I need code, it’s almost always going to be a one-line snippet that I can just hurl into a Set Variable widget, or worst-case, a few lines in a code block. I’m not looking to create my own classes or delegates or what have you; I can go as far as a Func<>
and that’s about it.
With that, I have read the replies here several times and googled about lambdas, but nothing is connecting for me.
Am I beneath the intelligence of this thread? Probably. But then there’s “What is a variable,” and like the Jeopardy viewer who gets one question right and thinks, “I could totally be on that show,” I too feel like I can hang with the crew here.
So, all of that is to preface the simple point of: I simply don’t get it with lambdas.
Here’s what I am piecing together:
- Lambda expressions are a single line (no need for curly braces or other programmer stuff),
- Lambda statements are multi-line, with curly braces and semicolons galore, and the word
return
in there. But it’s essentially an expanded version of #1.
a. (This doesn’t get me any closer to having a clue.) - There’s a scope thing going on here (bet you didn’t know I knew that word).
a. What’s funny is that several of you point out that lambdas can see outer objects (I see this is a trade phrase), implying that normal is that inner objects cannot see outer objects? Is that right?
b. (I am used to innermost objects having the most limited scope - outer has global scope and can be seen by anything inside of it, while inner cannot be seen by outer unless you do something wacky.)
c. (Still no closer to understanding) - Can I get some parentheses on this?! What on earth is the order of operations here?
I think it’s
Db.PerCon.Where((p => p.PerConID) == "ROCK")
I don’t even know if that would work or not, but my point is, is that what is logically happening?
But my most fundamental question is: What kind of thing is a lambda returning? Is it a list? Is it more like a representation of a field in a table?
I have to run, but that’s what I have so far. Thanks to anyone that might still be bearing with me.