Does it mean that Line is an alias for Struct now?
No. That would be something like
Line = Struct
Line = Struct.new(name, "example") // what happens here?
- Dereference the constant
Struct - send the message
name without arguments to self - send the message
new with two arguments to the object returned in 1, the first argument is the object returned in 2., the second argument is the literal string "example" - assign the object returned in 3. to the constant
Line
Line.new(name, z[:specific]) // equal to 'Struct.new'?
No, that's not how assignments work in Ruby. In Ruby, you don't assign an expression to a variable, the expression gets evaluated first, and then the result of that evaluation gets assigned to the variable once.
I.e. if you do something like
foo = gets
gets does not get called over and over again, every time you dereference foo, it gets called once when you assign to foo and then foo contains a reference to the object returned by gets.
Besides, even if it worked like you seem to think it does, then it still wouldn't be equal to Struct.new but rather to Struct.new(name, "example").new, because that's the expression that was on the right-hand side of the assignment to Line (but, like I said, it doesn't work like that).