Skip to content

Commit

Permalink
Correct the example for CSV.generate_lines (#257)
Browse files Browse the repository at this point in the history
```ruby
3.0.0 :001'> CSV.generate_lines(['foo', '0'], ['bar', '1'], ['baz', '2'])
Traceback (most recent call last):
        3: from bin/console:14:in `<main>'
ArgumentError (wrong number of arguments (given 3, expected 1))
3.0.0 :002 > CSV.generate_lines([['foo', '0'], ['bar', '1'], ['baz', '2']])
 => "foo,0\nbar,1\nbaz,2\n" 
3.0.0 :003 > CSV.generate_lines(:foo)
Traceback (most recent call last):
        5: from bin/console:14:in `<main>'
        4: from (irb):12:in `<main>'
        3: from /csv/lib/csv.rb:1501:in `generate_lines'
        2: from /csv/lib/csv.rb:1409:in `generate'
        1: from /csv/lib/csv.rb:1502:in `block in generate_lines'
NoMethodError (undefined method `each' for :foo:Symbol)
```
  • Loading branch information
sampatbadhe authored Aug 27, 2022
1 parent 8bac060 commit a171621
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1489,12 +1489,12 @@ def generate_line(row, **options)
# ---
#
# Returns the \String generated from an
# CSV.generate_lines(['foo', '0'], ['bar', '1'], ['baz', '2']) # => "foo,0\nbar,1\nbaz.2\n"
# CSV.generate_lines([['foo', '0'], ['bar', '1'], ['baz', '2']]) # => "foo,0\nbar,1\nbaz,2\n"
#
# ---
#
# Raises an exception
# # Raises NoMethodError (undefined method `find' for :foo:Symbol)
# # Raises NoMethodError (undefined method `each' for :foo:Symbol)
# CSV.generate_lines(:foo)
#
def generate_lines(rows, **options)
Expand Down

0 comments on commit a171621

Please sign in to comment.