[MacRuby-devel] [MacRuby] #146: Crash While Using CSV
MacRuby
ruby-noreply at macosforge.org
Sat Aug 29 13:38:49 PDT 2009
#146: Crash While Using CSV
--------------------------------+-------------------------------------------
Reporter: ted.reed@… | Owner: lsansonetti@…
Type: defect | Status: closed
Priority: major | Milestone: MacRuby 0.5
Component: MacRuby | Resolution: fixed
Keywords: |
--------------------------------+-------------------------------------------
Changes (by lsansonetti@…):
* status: new => closed
* resolution: => fixed
* milestone: => MacRuby 0.5
Comment:
Looks like this is fixed in trunk.
{{{
$ cat t.rb
require 'csv'
filename = "t.csv"
friends = []
class Friend
attr_accessor :first_name, :last_name, :phone_number,
:email_address
end
reader = CSV.open(filename, 'r')
reader.each do |row|
# All of this inside the loop can be commented out and the outcome
is the same.
friend = Friend.new
friend.first_name = (row[0] || "")
friend.last_name = (row[1] || "")
friend.phone_number = (row[2] || "")
friend.email_address = (row[3] || "")
friends << friend
end
reader.close
p friends
}}}
{{{
$ ./miniruby t.rb
[##-<Friend:0x20031abe0 @first_name="John", @last_name="Smith",
@phone_number="", @email_address="">, ##-<Friend:0x20031e7e0
@first_name="John", @last_name="Smith", @phone_number="",
@email_address="">, ##-<Friend:0x20031fd80 @first_name="John",
@last_name="Smith", @phone_number="555-1212", @email_address="">,
##-<Friend:0x2003210c0 @first_name="John", @last_name="Thompson",
@phone_number="", @email_address="">]
$ ruby19 t.rb
[#<Friend:0x00000100a68438 @first_name="John", @last_name="Smith",
@phone_number="", @email_address="">, #<Friend:0x00000100a67e48
@first_name="John", @last_name="Smith", @phone_number="",
@email_address="">, #<Friend:0x00000100a67808 @first_name="John",
@last_name="Smith", @phone_number="555-1212", @email_address="">,
#<Friend:0x00000100a67240 @first_name="John", @last_name="Thompson",
@phone_number="", @email_address="">]
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/146#comment:2>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list