The docs on the Wiki for the custom serializer needs a little updating. The current example wouldn't be able to compile
class SpecialtyObject
property name : String
property value : Int32
+ def initialize(@name, @value)
+ end
end
def deserialize_specialty_object(raw : String) : SpecialtyObject
- specialty = SpecialtyObject.new
parts = raw.split "="
- specialty.name = parts.first
- specialty.value = parts.last
+ SpecialtyObject.new(name: parts.first, value: parts.last)
end
In this case, the method has to return the instance of SpecialtyObject, plus crystal requires the instance variables to be initialized in some initialize method.
The docs on the Wiki for the custom serializer needs a little updating. The current example wouldn't be able to compile
In this case, the method has to return the instance of
SpecialtyObject
, plus crystal requires the instance variables to be initialized in some initialize method.