Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

File::Stat#<=>

stat <=> other_stat → -1, 0, 1, nil

Compares File::Stat objects by comparing their respective modification times.

nil is returned if other_stat is not a File::Stat object

Example
f1 = File.new("f1", "w")
sleep 1
f2 = File.new("f2", "w")
f1.stat <=> f2.stat   #=> -1
See also .new #atime #birthtime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1