ruby remove last element from array code example
Example 1: ruby pop array
a = [1, 2, 3, 4]
a.pop()
# => 4
Example 2: ruby remove last element of string
'abc1234'.chomp(4) # => 'abc123'
'toto'.chomp('to') # => 'to'
a = [1, 2, 3, 4]
a.pop()
# => 4
'abc1234'.chomp(4) # => 'abc123'
'toto'.chomp('to') # => 'to'