Module: Kernel

Defined in:
lib/kernel.rb,
lib/kernel/symbol.rb

Overview

The Kernel module.

Instance Method Summary collapse

Instance Method Details

#Symbol(arg) ⇒ Symbol

Note:

Converts arg to a string and then converts the string to a symbol.

Returns arg as a Symbol.

Examples:

require "kernel/symbol"

Symbol(:foo)            # => :foo
Symbol("foo")           # => :foo
Symbol(true)            # => :true
Symbol(42)              # => :"42"
Symbol(BasicObject.new) # TypeError (can't convert BasicObject into String)

Parameters:

  • An object.

Returns:

  • Returns arg as a Symbol.

Raises:

  • Not conform with symbol representation.



23
24
25
# File 'lib/kernel/symbol.rb', line 23

def Symbol(arg)
  :"#{String(arg)}"
end