A small example about how Ruby is evolving
A small example about how #Ruby is evolving.
I took a code sample from a feature request from 2011 and wrote it using features that will be available in Ruby 3.4
![Example of refactoring using endless method](https://cdn.scribbles.page/rails/active_storage/representations/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1VXIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--77e2cb03930aecc6443fd78e8615b3da18f96818/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9MWm05eWJXRjBTU0lJY0c1bkJqb0dSVlE2RkhKbGMybDZaVjkwYjE5c2FXMXBkRnNIYVFJQUNHa0NBQVk2Q25OaGRtVnlld2M2Q25OMGNtbHdWRG9NY1hWaGJHbDBlV2xrIiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--768aeab7fb7843d85fe5b2b4ba237e06e6ef604f/c35fd208-762b-4eef-8deb-174d5b30992f.png)
In case you are wondering, _1
is called a numbered block parameter,
and in this case, it is a shorthand syntax for the first parameter in
that block.
![Example of numbered block params](https://cdn.scribbles.page/rails/active_storage/representations/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBb1lXIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--9b6b0e8673ccedcc058ed99e0955c7af7e4919a9/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9MWm05eWJXRjBTU0lJY0c1bkJqb0dSVlE2RkhKbGMybDZaVjkwYjE5c2FXMXBkRnNIYVFJQUNHa0NBQVk2Q25OaGRtVnlld2M2Q25OMGNtbHdWRG9NY1hWaGJHbDBlV2xrIiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--768aeab7fb7843d85fe5b2b4ba237e06e6ef604f/0c60d797-2207-428d-8ae9-a762fc45ba2e.png)
You can play with it
block param already using https://ruby-next.github.io