Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby remove last element of string

'abc1234'.chomp(4) # => 'abc123'
'toto'.chomp('to') # => 'to'
Comment

how to remove last element from array in ruby

prices = [10, 20, 30, 40]

prices.pop

puts prices
Output:

[10, 20, 30]
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby array append vs push 
Ruby :: ruby change directory 
Ruby :: rails check routes in console 
Ruby :: rails catch mail error 
Ruby :: ruby group by 
Ruby :: how add an index column in rails 
Ruby :: text_field_tag rails 
Ruby :: rails image tag data attribute 
Ruby :: rails find_by 
Ruby :: remove ascii characters from string ruby 
Ruby :: rails model naming convention 
Ruby :: rails get random record 
Ruby :: ruby conditionals 
Ruby :: ruby array split into groups 
Ruby :: rbenv not changing version 
Ruby :: filter through array of arrays ruby 
Ruby :: rails add column next to 
Ruby :: linker command failed with exit code 1 ruby 
Ruby :: setp in ruby loop 
Ruby :: Validate French phone numbers 
Ruby :: pick element from array that is part of params hash 
Ruby :: ruby zip rows and columns 
Ruby :: bundle add cloudinary rails 
Ruby :: array sort_by nil ruby 
Ruby :: rspec change matcher 
R :: vertical line in ggplot2 
R :: scale between 0 and 1 R 
R :: r test normality 
R :: how to read file in r 
R :: how to change the index of a dataframe in r 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =