Closed Nowaker closed 9 years ago
#[]
is inherited from OpenStruct, and it hasn't been reimplemented. I think it makes sense to have both object[:element]
and object.element
return the same value.
If you'd like the behavior in RecursiveOpenStruct, feel free to submit a PR.
OK, thanks. This is very reasonable, because of being able to use map(&:something).inject(0, &:+)
. Otherwise map { |e| e[:something] }.inject(0, &:+)
is needed. The first is better. :-) Will submit.
I originally thought RecursiveOpenStruck is lost after map() call. I had a mistake - I did
object[:element]
instead ofobject.element
. However, shouldn't both calls just return RecursiveOpenStruck for the sake of consistency?