Skip to content

Instantly share code, notes, and snippets.

@emonti
Created January 17, 2010 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emonti/279607 to your computer and use it in GitHub Desktop.
Save emonti/279607 to your computer and use it in GitHub Desktop.
# copy and paste this into IRB...
#
require 'ffi'
class Foo < FFI::Struct
layout :ary, [:uint16, 10]
end
f = Foo.new
# => #<Foo:0x19bb51c>
f[:ary].class
# => FFI::Struct::InlineArray
# and something with InlineArray is broken...
f[:ary]
# NoMethodError: to_s not defined for this array type
# from /usr/lib/ruby/1.8/irb.rb:302:in `to_s'
# from /usr/lib/ruby/1.8/irb.rb:302:in `inspect'
# from /usr/lib/ruby/1.8/irb.rb:302:in `output_value'
# from /usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
# from /usr/lib/ruby/1.8/irb.rb:263:in `signal_status'
# from /usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
# from /usr/lib/ruby/1.8/irb/ruby-lex.rb:244:in `each_top_level_statement'
# from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in `loop'
# from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in `each_top_level_statement'
# from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in `catch'
# from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in `each_top_level_statement'
# from /usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
# from /usr/lib/ruby/1.8/irb.rb:70:in `start'
# from /usr/lib/ruby/1.8/irb.rb:69:in `catch'
# from /usr/lib/ruby/1.8/irb.rb:69:in `start'
# from /usr/bin/irb:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment