Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mosaheh/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#shift!String

Removes the first charecter from the String and returns it back

Examples:

str = 'abc'
str.shift! # => 'a'
p str      # => 'bc'

Returns:

  • (String)

    The removed first charecter



12
13
14
15
16
# File 'lib/mosaheh/core_ext/string.rb', line 12

def shift!
  char = self[0]
  self[0] = ''
  char
end