We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
require 'csv'; CSV.generate { |csv| csv << {a: 1, b: 2} }
undefined method 'collect' for nil
What's weird is that it works with structs (and arrays of course) but not with hashes
>> require 'csv'; CSV.generate { |csv| csv << {a: 1, b: 2} } /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/csv-3.3.0/lib/csv/writer.rb:36:in `<<': undefined method `collect' for nil (NoMethodError) row = @headers.collect {|header| row[header]} ^^^^^^^^ from /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/csv-3.3.0/lib/csv.rb:2373:in `<<' from (irb):2:in `block in <top (required)>' from /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/csv-3.3.0/lib/csv.rb:1410:in `generate' from (irb):2:in `<main>' from <internal:kernel>:187:in `loop' from /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/irb-1.14.0/exe/irb:9:in `<top (required)>' from /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/bin/irb:25:in `load' from /Users/dorianmariefr/.asdf/installs/ruby/3.3.4/bin/irb:25:in `<main>'
The text was updated successfully, but these errors were encountered:
You need to specify headers:: CSV.generate(headers: [:a, :b]) {|csv| csv << {a: 1, b: 2}}
headers:
CSV.generate(headers: [:a, :b]) {|csv| csv << {a: 1, b: 2}}
Sorry, something went wrong.
No branches or pull requests
What's weird is that it works with structs (and arrays of course) but not with hashes
The text was updated successfully, but these errors were encountered: