News for hackers. Stuff that matters.
Re:Rails is not written in Ruby by amw-zero on Saturday February 05, 2022 @01:54AM (#30218524)
Now replace |> with . And you have the previous code example. The difference is completely superficial.
Re:Rails is not written in Ruby by jonnycat on Saturday February 05, 2022 @07:28AM (#30220380)
The end result is superficially different. That's the point - we like the flow of the end result! But the implementation is completely different, as it's pure functional compared to object oriented.

"string".do_stuff() - do_stuff() is a method on the "string" class, with all of the potential gotchas that might come with an OO implementation. Does the method mutate the internal state of the object? Does the particular class override the default implementation? Is it a monkey-patched implementation (the issue raised by this article)?

"string" |> do_stuff() - do_stuff() is a standalone pure function. The data is immutable and does exactly what it says.

Re:Rails is not written in Ruby by machiaweliczny on Saturday February 05, 2022 @06:40AM (#30220162)
It's not because you can use any function with pipeline and with dots chaining you can use only methods returned by previous function call.
Re:Rails is not written in Ruby by kazinator on Saturday February 05, 2022 @01:17PM (#30223938)
That is false; you cannot chain functions that do not return a value that is suitable as an argument to the next function.

a.this().that() requires that a.this() returns an object on which .that() can be invoked.

(that (this a)) requires that (this a) returns an object that is a suitable argument to that.

Re:Rails is not written in Ruby by kazinator on Saturday February 05, 2022 @01:15PM (#30223914)
Not completely, because the . has a meaning: select a member/field/slot from a class object.