Skip to content

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

instance method

CSV::Table#==

table == other_table → true or false

Returns true if all each row of self == the corresponding row of other_table, otherwise, false.

The access mode does no affect the result.

Equal tables:

Example
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
other_table = CSV.parse(source, headers: true)
table == other_table # => true

Different row count:

Example
other_table.delete(2)
table == other_table # => false

Different last row:

Example
other_table << ['bat', 3]
table == other_table # => false
See also #<< #[] .new #[]= also in 3.2 · 3.1 · 3.0