Get last character in string
UPDATE: I keep getting constant up votes on this, hence the edit. Using [-1, 1] is correct, however a better looking solution would be using just [-1]. Check Oleg Pischicov’s answer. line[-1] # => “c” Original Answer In ruby you can use [-1, 1] to get last char of a string. Here: line = “abc;” … Read more