Struct :symbol vs 'string' difference

(Thomas Hurst) #1

If Struct#new’s first argument is a string, it’s used as the name of the
structure within Struct::, otherwise it’s just returned as an anonymous
class object.

It’s not surprising if you read the docs :wink:


Bar =‘Bar’, :a, :b, :c), 2, 3) -> #<Struct::Bar a=1, b=2, c=3>

Foo =, :a, :b, :c), 2, 3) -> #

I’m wondering why there is this difference, which I found surprising.

Thomas ‘Freaky’ Hurst - -

She missed an invaluable opportunity to give him
a look that you could have poured on a waffle.