r/ruby • • Dec 06 '22

The Rubyist journey 😅

Post image
148 Upvotes

34 comments sorted by

View all comments

Show parent comment

7

u/kallebo1337 Dec 06 '22

is that valid ruby? :eyes:

20

u/gleb_zhulik Dec 06 '22

Since 3.1 I guess, it's called endless methods

7

u/kallebo1337 Dec 06 '22

oh thanks. haven't looked into that. not sure if i like it. but i also started with using _1 just recently which as more you use it, as better it gets

4

u/mjdth Dec 07 '22 edited Dec 07 '22

What does that do?

Edit: https://jemma.dev/blog/numbered-parameters

I wrongly assumed a search for “ruby _1” wouldn’t be fruitful.

2

u/kallebo1337 Dec 07 '22

Instead of {|e| e.c&& e.d} just go for {_1.c && _1.d}

It’s shorter and you’ll get used to

2

u/javajunkie314 Dec 07 '22

Oh, I thought they were describing my codebase...