Consider ``` Foo = Data.define(:x) Foo.new(1) => {x:, z:} ``` It raises `#<data Foo x=1>: key not found: :x (NoMatchingPatternKeyError)` Clearly the message is misleading, as it is key :z that is missing.esad (Esad Hajdarevic)
There is an example in Control Expressions documentation: ``` p a if a = 0.zero? # raises NameError “undefined local variable or method ‘a’”. ``` However, if we had already defined `a` there would be no exception raised. If one u...esad (Esad Hajdarevic)
Is there a reason why this doesn't work with keyword arguments too? For example: ``` def foo(bar:, ...) other(...) end ``` results in syntax error esad (Esad Hajdarevic)
Ok I was too quick on this one. module keyword returns last expression in the block, so just ending module declaration with self works: ``` using(module Foo refine ... self end) ``` so this request can be closedesad (Esad Hajdarevic)
Currently module keyword returns nil after defining a new module: ``` x = module Foo end # x is nil ``` It would be more consistent with `Module.new` if module keyword returned the newly defined module. Then we could do: ```...esad (Esad Hajdarevic)
I've stumbled upon unexpected behaviour of lazy enumerators. My example: ``` [1].cycle.lazy.zip([2].cycle.lazy).map do |x| puts x.inspect end.take(5).force puts "---" [1].cycle.lazy.zip([2].cycle.lazy).take(5).force.map do |x| ...esad (Esad Hajdarevic)
When I run this script ``` echo = Ractor.new { Ractor.receive } Thread.new { puts Ractor.select(echo).inspect } sleep 0.1 echo.send "test" ``` the script never terminates. If I change thread body to ``` Thread.new { puts...esad (Esad Hajdarevic)
nobu (Nobuyoshi Nakada) wrote in #note-9: > That example does not need `Ractor`. Yes, you are right, it actually doesn't need Thread either, and is simply about calling a block in a loop and how to break the loop from the called bloc...esad (Esad Hajdarevic)
ufuk (Ufuk Kayserilioglu) wrote in #note-7: > @esad If you just want to return a result from the `loop`, you can use `break <value>` to do that: > ... Calling break from a block passed to a ractor will raise an exception. I think some sa...esad (Esad Hajdarevic)
nobu (Nobuyoshi Nakada) wrote in #note-3: > I'm curious what your use case is. > ... I think my use case is a bit of an edge case - I am passing a block into a Ractor where it runs in a loop. This way I can control exit from the loop, ...esad (Esad Hajdarevic)