I need to create a Struct with multiple fields (based on a long string). Here is what I have so far:
s = "a1|b2|c3|"
a = s.split("|")
b = []
a.each { |e|
b.push(e.to_sym)
}
Str = Struct.new(*b)
Anyway to make it shorter?
I need to create a Struct with multiple fields (based on a long string). Here is what I have so far:
s = "a1|b2|c3|"
a = s.split("|")
b = []
a.each { |e|
b.push(e.to_sym)
}
Str = Struct.new(*b)
Anyway to make it shorter?