1. 5
  1.  

  2. 4

    I’ve got mixed feelings about this. It’s yet another syntax for Ruby, which is already fairly complicated. It is very close to duplicating pre-existing functionality in the form of Struct and OStruct - neither of which I actually like using because there’s no built-in immutability. I don’t know that this proposal is HARMFUL, but neither do I know that it is a benefit. So, “meh”

    1. 3

      I like using Structs in Ruby, especially as a form of documentation and, as the author said, ensuring that a key passed in doesn’t silently fail. It’s much easier to see the options available for a bit of code where the struct is defined in one place instead of hunting for accessors of a hash.

      That being said, I don’t like this syntax at all. It just adds yet another way of doing something when, I feel, the current way is sufficient and easy enough already.

      1. 3

        I’ve been using dry-struct for this reason, in concert with dry-types, and I really like it.