Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

File::Stat#sticky?

() -> bool
sticky? → true or false

Returns whether the sticky bit is set in the special bits for self:

Example
filepath = '/tmp/t.tmp'
File.write(filepath, 'foo')
stat = File.stat(filepath)
stat.sticky?                # => false
stat.mode.to_s(8)           # => "100664"
File.chmod(01644, filepath) # => 1        # Stat unchanged.
stat.sticky?                # => false
stat.mode.to_s(8)           # => "100664"
stat = File.stat(filepath)                # Fresh stat.
stat.sticky?                # => true
stat.mode.to_s(8)           # => "101644"
File.delete(filepath)                     # Clean up.

Returns false on Windows.

See also #socket? #symlink? #size? #uid also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0