class Symbol

include Comparable[Symbol]

A name, written :name (or :"any text"): interned, so equal symbols are the same value and compare in constant time. Used for hash keys, options and enum-like values.

<prelude>:2704

Methods

def <=>(other: Symbol) -> Int

Compares the names as strings.

<prelude>:2709

def to_s -> String

The name, without the colon.

<prelude>:2711

def to_sym -> Symbol

The symbol itself.

<prelude>:2713

def inspect -> String

The literal: :abc, quoted when the name is not an identifier.

:abc.inspect       # => ":abc"
:"a b".inspect     # => ":\"a b\""

<prelude>:2720

def size -> Int

The number of characters in the name.

<prelude>:2722

def length -> Int

The number of characters in the name.

<prelude>:2724

def empty? -> Bool

Whether the name is empty (:"").

<prelude>:2726

def upcase -> Symbol

The symbol with the name in upper case.

<prelude>:2728

def downcase -> Symbol

The symbol with the name in lower case.

<prelude>:2730

def capitalize -> Symbol

The symbol with the name's first character in upper case and the rest in lower case.

<prelude>:2733

def succ -> Symbol

The symbol whose name is the name's successor, as String#succ.

:az.succ   # => :ba

<prelude>:2739

def start_with?(*prefixes: String) -> Bool

Whether the name starts with one of prefixes.

<prelude>:2741

def end_with?(*suffixes: String) -> Bool

Whether the name ends with one of suffixes.

<prelude>:2743