From: why the lucky stiff Date: 2004-03-13T07:42:43+09:00 Subject: Re: saving array Phidippus wrote: >TypeError: can't dump NArray > from /usr/local/lib/ruby/1.6/pstore.rb:111:in `dump' > from /usr/local/lib/ruby/1.6/pstore.rb:111:in `transaction' > from (irb):5 > > Here's one way to do it in YAML. Hopefully we can make this simpler in the future. Not too bad for now. class NArray def is_complex_yaml? true end def to_yaml_type "!ruby/narray" end def to_yaml( opts = {} ) opts[:DocType] = self.class if Hash === opts YAML::quick_emit( self.object_id, opts ) { |out| out.seq( to_yaml_type ) { |seq| seq.concat( self.to_a ) } } end end YAML.add_ruby_type( 'narray' ) { |type, val| NArray[ *val ] ) } _why