summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorYuki Tsujimoto <46666464+ytjmt@users.noreply.github.com>2023-03-14 05:40:13 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-05-25 01:44:17 +0900
commite151a2ff8ecfb26172c8e9643b53b00276658a50 (patch)
tree182458cad089b98b39bffc7e26ef4a10a63a8605 /doc
parent88876f02c1050be989500090763203a36c70597b (diff)
[ruby/csv] docs: fix example in Recipe: Capture Unconverted Fields
(https://github.com/ruby/csv/pull/276) I've fixed the example in `Recipe: Capture Unconverted Fields`. https://ruby.github.io/csv/doc/csv/recipes/parsing_rdoc.html#label-Recipe-3A+Capture+Unconverted+Fields `parsed` is wrong: header row is missing and the values should be integers. ``` $ ruby -v ruby 3.2.1 (2023-02-08 revision https://github.com/ruby/csv/commit/31819e82c8) [x86_64-darwin21] $ cat unconverted_fields.rb require "csv" source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" parsed = CSV.parse(source, converters: :integer, unconverted_fields: true) p parsed parsed.each {|row| p row.unconverted_fields } $ ruby unconverted_fields.rb [["Name", "Value"], ["foo", 0], ["bar", 1], ["baz", 2]] ["Name", "Value"] ["foo", "0"] ["bar", "1"] ["baz", "2"] ```
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7851
Diffstat (limited to 'doc')
-rw-r--r--doc/csv/recipes/parsing.rdoc2
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/csv/recipes/parsing.rdoc b/doc/csv/recipes/parsing.rdoc
index bcc6bd00cd..f3528fbdf1 100644
--- a/doc/csv/recipes/parsing.rdoc
+++ b/doc/csv/recipes/parsing.rdoc
@@ -520,7 +520,7 @@ Apply multiple header converters by defining and registering a custom header con
To capture unconverted field values, use option +:unconverted_fields+:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
parsed = CSV.parse(source, converters: :integer, unconverted_fields: true)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
+ parsed # => [["Name", "Value"], ["foo", 0], ["bar", 1], ["baz", 2]]
parsed.each {|row| p row.unconverted_fields }
Output:
["Name", "Value"]