there are functions that look for the amount of parameters that gets spooked by this: ```ruby data = { 'a' => 1, 'b' => 2, 'c' => 3 } data.each &proc {|a,| p a } #=> "a", "b", "c" data.each &lambda {|a,| p a } #=>["a", 1], ["...Hanmac (Hans Mackowiak)
You might want a different function. `Enumerable#each_with_index` does reset the Enumerator, while `Enumerator#with_index` does not. ```ruby p 3.times.lazy.take(0).each_with_index.to_a #[[0, 0], [1, 1], [2, 2]] p 3.times.lazy.take(0).w...Hanmac (Hans Mackowiak)
Isn't it easier to use sort_by instead? And then use an Array as Sorting Field? ```ruby array.sort_by {|o| [o.y, -o.x] } #=> [#<struct Point x=5, y=2>, #<struct Point x=2, y=2>, #<struct Point x=1, y=2>, #<struct Point x=6, y=4>] ```Hanmac (Hans Mackowiak)
@artur86 the difference between these two are the module nesting See this doku about this: https://ruby-doc.org/3.2/syntax/modules_and_classes_rdoc.html#label-Constants In Short, the second variant can raise NameError if you don't ...Hanmac (Hans Mackowiak)
These are called `virtual variables`, a new object is created each time you try to access it ```c rb_define_virtual_variable("$~", get_LAST_MATCH_INFO, match_setter); rb_define_virtual_variable("$&", last_match_getter, 0); ...Hanmac (Hans Mackowiak)
we need to be careful with this, because while `0.1E-9` is also a valid ruby literal, `0.E-9` is not. (unknown method E for 0) `1E-9` is valid literal againHanmac (Hans Mackowiak)
nobu (Nobuyoshi Nakada) wrote in #note-2: > Probably you may want to do: > ... Pathname class already has this kind of logic in the `<=>` function it just doesn't include the `Comparable` module to add the other compare functions li...Hanmac (Hans Mackowiak)