General

Profile

3limin4t0r (Johan Wentholt)

  • Login: 3limin4t0r
  • Registered on: 12/03/2018
  • Last sign in: 10/27/2022

Issues

open closed Total
Assigned issues 0 0 0
Reported issues 1 0 1

Activity

11/18/2019

01:16 PM Ruby Feature #15563: #dig that throws an exception if a key doesn't exist
Removed the two discussion points in the previous edit. This edit adjusts the last sentence to reflect this. 3limin4t0r (Johan Wentholt)
01:08 PM Ruby Feature #15563: #dig that throws an exception if a key doesn't exist
Changed naming from `#dig_e` to `#traverse`. Removed alternative options, and kept the strict version since `#fetch` is also strict. Possibility to expand upon this with a block or `:default` keyword argument is possible, but should be i... 3limin4t0r (Johan Wentholt)

01/28/2019

05:06 PM Ruby Feature #15563: #dig that throws an exception if a key doesn't exist
My scenario would be similar to k0kubuns scenario.
```Ruby
# The connection translates the request to JSON and parses the response
# from JSON into the correct objects. In this case a nested hash structure.
response = connection.se...
3limin4t0r (Johan Wentholt)

01/25/2019

05:48 PM Ruby Feature #15563: #dig that throws an exception if a key doesn't exist
I just discovered that `#dig` also call private methods. I updated the provided examples to do the same.
```Ruby
hash = { b: 'b' }
hash.singleton_class.send(:private, :dig)
{ a: hash }.dig(:a, :b)
#=> 'b'
```
3limin4t0r (Johan Wentholt)
05:07 PM Ruby Feature #15563 (Open): #dig that throws an exception if a key doesn't exist
Ruby 2.3.0 introduced `#dig` for `Array`, `Hash` and `Struct`. Both `Array` and `Hash` have `#fetch`, which works the same way as `#[]`, but instead of returning the default value, raises an exception (unless a second argument or block i... 3limin4t0r (Johan Wentholt)

Also available in: Atom