I have no idea if it will make a different, but do you realize that by
calling collect you are creating an array whose entries are the return
value of puts (which is always nil). An array of over 1000 nil entries.
I think you probably want either:
arrayName.each{ |x| puts x.inspect }
or
puts arrayName.collect{ |x| x.inspect }
value of puts (which is always nil). An array of over 1000 nil entries.
I think you probably want either:
arrayName.each{ |x| puts x.inspect }
or
puts arrayName.collect{ |x| x.inspect }
True, but it shouldn’t segfault in any case. I’m curious what the
objects of arrayName look like. I was not able to duplicate this
problem with a 10000 element array of simple objects.
value of puts (which is always nil). An array of over 1000 nil entries.
I think you probably want either:
arrayName.each{ |x| puts x.inspect }
or
puts arrayName.collect{ |x| x.inspect }
This is also a nice alternative to try:
require ‘pp’
pp arrayName
And, btw, in Ruby we conventionally use underscores instead of camelCase
so array_name is preferred. Of course that is a pretty meaningless
identifier so that should probably named differently altogether.
True, but it shouldn’t segfault in any case. I’m curious what the
objects of arrayName look like. I was not able to duplicate this
problem with a 10000 element array of simple objects.
Yeah, OP what objects do you have in that array? Are you using some
kind of C extension? Is this a recursive data structure?
Regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.