|
Ermmm, no, because that is like saying 2 + 2 = 3, because 3 is nearly 4
|
|
|
|
|
In the C# chain, methods may return the same or different objects at any stage.
The WITH block just calls the methods on the original object.
IThing thing = new ThingBuilder()
.AddTitle("I'm a Thing!")
.CreatePreciousThing()
.SetPreciousLevel(100);
|
|
|
|
|
Finally it comes up to the same from a user point ...
|
|
|
|
|
Well, no. I must admit that I do not use C#, only know the very basics of it.
"new" in C# is creating an instance of an previously defined object (MyFluentAPI) and executes those 3 methods.
As for "Pascal", you did not mentioned which kind of Pascal you are using.
In "standard" Pascal (including but not limited to ISO7185), the "with" statement is used to set the scope for the statements within the begin...end block, and is used in connection with "records" ("struct" in C) to save on some typing, as you would not have to precede each record element with its associated record name. But in this case, those elements within that record are purely data!
It is purely what sometimes these days is referred to as "syntactic sugar".
But the major difference is that the record (and in extension, this applies mostly to objects/classes in Object Pascal (Delphi/FreePascal) as well) needs to be existing (already instantiated) when you are referring to it using the "with" statement (block).
If you are using the "with" statement in either standard/procedural Pascal or Object Pascal, you need to do this carefully, as, while it saves some typing and the source code lines shorter, it can lead to some nasty side effects/bugs (or features ) if you have elements, like data or methods/procedure/functions with the same names in different records/methods/etc...
|
|
|
|
|
Not quite.
While the code sample you posted may look fluent, in reality the functions DoThis() , DoThat() and DoAnother() all operate on a myFluentThing . A truly fluent piece of code contains chained methods each of which operate on the context of the previous returned type.
So unless I misunderstood what you wrote, I don't think you'd be able to simulate this in Pascal:
int i = new FooBuilder()
.Build()
.DoSomethingToFoo()
.DoSomethingElseToFoo()
.GetAnEnumerableIntPropertyOfFoo()
.Sum(); /ravi
|
|
|
|
|
Of course you are right, nitpicker
|
|
|
|
|
So stringing things together is great?
Then you should try Lisp.
|
|
|
|
|
Wordle 1,065 4/6*
⬛🟨⬛⬛⬛
⬛🟨🟨⬛🟨
⬛🟩⬛🟨🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,065 4/6
⬛⬛⬛⬛🟨
🟨⬛⬛🟨⬛
🟨🟨🟨🟩⬛
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,065 6/6*
⬜⬜⬜⬜⬜
🟨⬜⬜🟨🟨
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
Close ... too close ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 1,065 5/6
⬜⬜🟨⬜⬜
⬜⬜⬜🟨⬜
⬜🟩⬜⬜⬜
🟨🟩⬜🟨⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
🟨⬜⬜⬜⬜
⬜🟩⬜⬜⬜
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 1,065 6/6
⬛⬛⬛⬛⬛
⬛🟩🟩🟨⬛
⬛🟩🟩⬛⬛
⬛🟩🟩🟩🟩
⬛🟩🟩🟩🟩
🟩🟩🟩🟩🟩
This one took me too long!
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 1,065 3/6
🟩⬛⬛⬛🟨
🟩⬛⬛🟨⬛
🟩🟩🟩🟩🟩
Jeremy Falcon
|
|
|
|
|
You'll strain your voice.
*runs away*
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
good one
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Did you hear about the elephant who ran into a screen door? He strained himself.
(Heard on Dr. Demento in the 80s if I recall correctly.)
The Lounge[^]
modified 19-May-24 12:15pm.
|
|
|
|
|
See title - doctors and nurses should get more attention than this crap - just sayin
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
had to look up the names to see what it is supposed to be about. I'll just reinsert my head into the sand, it's nice and warm there !
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I do not know what it is, but looking at your comment, I think I'll be happier preserving my ignorance.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I decided not to search the term too.
Ah...Ignorance truly is bliss.
|
|
|
|
|
what's worse? Ignorance or indiference?
I don't know it and I don't care
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Good point ... BTW do you know who won ?
modified 18-May-24 19:25pm.
|
|
|
|
|
Usyk won on points from a split decision.
|
|
|
|
|
pkfox wrote: doctors and nurses should get more attention Well that's a different issue. Boxing is still an interesting sport.
|
|
|
|