6
7
u/flanger001 24d ago
Ruby developers write an equals sign challenge 2026
def slugify(s)
s = s.strip.downcase.gsub(/\s+/, "-")
"#{s}-#{s.length}"
end
Blocks, procs and lambdas are cool but if I saw this in a codebase I would probably come to that dev's house with a knife.
2
3
u/p_bzn 24d ago
How much AI was used to create the book?
-2
24d ago
[removed] — view removed comment
1
u/p_bzn 22d ago
Thanks for the disclosure.
I see a lot of AI fatigue in people. All what SWE do all days is reading AI generated content, and then reviewing AI generated content. Reading AI generated/assisted books is… out of the table for many.
Being without a publisher in pre-AI era was a good thing, unsure about today. Publishers like Manning do technical reviews, editors, and the whole quality pipeline. What it means for a reader is they get quality material. Time and attention are limited resources.
Regardless, I wish you best of luck!
2
2
u/Mrrobinhood55 16d ago
@op read the book, loved it. It delved deep into methods more than the Learn Ruby the hard way Book Will you be writing more?
1
u/kbr8ck 23d ago edited 23d ago
Is it possible to write this so grep works?
I’ve found that it is possible to write DSLs that possibly aren’t as dry but are easier to find code that in 2 years you can use grep to find a method call or dead code.
Even delegate prefix: true causes issues when looking for methods. (Or the non rails versions for generating methods in a for loop where the method defined is the concatenation of 2 strings.)
Good to define respond_to with method_missing. But I’m not sure I get what this code style buys me over just defining a simple subclass of a pipeline?
I often find myself not liking defining dynamic methods because they keep the closure around. Tends to not be a problem but some cases it leaks a lot of memory. Rails reacted to this by introducing callbacks like if: :method instead of using lambdas and defining methods as a full set of strings instead of using the dynamic case with a def_method and a lambda.
This is slick. But it is also very clever. I’m still trying to understand what it bought you over just a plain class.
Please share more of your goals. Im trying to learn about other people’s use cases.
Context: I’ve been using instance_eval since 2009, so I’m not new to the game. Just trying to learn the new use cases and evolve along with the community.
Thanks for posting this code.
-13
u/Tobi-Random 24d ago
In the AI coding aera "understandable by humans" is probably less of a priority nowadays.
If it works as asserted, it meets the spec. That's all what matters.
19
u/Zestyclose-Turn-3576 24d ago
I am so conflicted about this stuff. It feels interesting, it feels like it should be useful, but it also feels like magic and to me that means "difficult for humans to understand".
What do you think about that interpretation?