Getting a substring in Ruby by x number of chars

How about this?

s[0, s.length - 3]

Or this

s[0..-4]

edit

s = "abcdefghi"
puts s[0, s.length - 3]  # => abcdef
puts s[0..-4]            # => abcdef

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş