-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
According to the docs Literal::Data
should behave in a hash-like way, however when I do the following it tells me []
is an undefined method.
Both are hash-like, meaning they can be used in place of a hash in some cases. You can access their properties using the [] method. Literal::Struct also supports []= to set properties.
Running v1.8
Sample code:
# frozen_string_literal: true
class ChartPoint < Literal::Data
prop :x, String
prop :y, _Union(Integer, Float)
end
Testing:
[1] pry(main)> f = ChartPoint.new(x: "foo", y: 12.1)
=> #<ChartPoint:0x00000001251bef10 @x="foo", @y=12.1>
[2] pry(main)> f[:x]
NoMethodError: undefined method `[]' for an instance of ChartPoint
Expected outcome:
[1] pry(main)> f = ChartPoint.new(x: "foo", y: 12.1)
=> #<ChartPoint:0x00000001251bef10 @x="foo", @y=12.1>
[2] pry(main)> f[:x]
=> "foo"
Literal::Struct
Works as expected.
Metadata
Metadata
Assignees
Labels
No labels