Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Struct #3

Open
Muriel-Salvan opened this issue Mar 31, 2014 · 0 comments
Open

Add support for Struct #3

Muriel-Salvan opened this issue Mar 31, 2014 · 0 comments
Assignees
Labels

Comments

@Muriel-Salvan
Copy link
Owner

Currently Structs are not supported correctly:

# Named Struct
User = Struct.new(:name, :age)
# => User
user = User.new('John', 49)
# => #<struct User name="John", age=49>
str = RubySerial.dump user
# => "1\x00\x82\xA3obj\x82\xA2\x00\xBB\xA4User\xA2\x00\xF1\x80\xABshared_objs\x80"
clone = RubySerial.load str
# => #<struct User name=nil, age=nil>

# Unnamed Struct
user = Struct.new(:name, :age).new('John',49)
# => #<struct name="John", age=49>
str = RubySerial.dump user
# => "1\x00\x82\xA3obj\x82\xA2\x00\xBB\xC0\xA2\x00\xF1\x80\xABshared_objs\x80"
clone = RubySerial.load str
# => {"\u0000\xBB"=>nil, "\u0000\xF1"=>{}}
clone == user
# => false
user.class
# => #<Class:0x2ed4540>
clone.class
# => Hash
@Muriel-Salvan Muriel-Salvan self-assigned this Mar 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant