Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

CSV::Row#field?

row.field?(value) → true or false

Returns true if value is a field in this row, false otherwise:

Example
source = "Name,Name,Name\nFoo,Bar,Baz\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.field?('Bar') # => true
row.field?('BAR') # => false
See also #field #field_row? #fetch #fields also in 3.2 · 3.1 · 3.0