title: Get last character in string
body: <p>I want to get the last character in a string MY WAY - 1) Get last index 2) Get character at last index, as a STRING. After that I will compare the string with another, but I won't include that part of code here. I tried the code below and I get a strange number instead. I am using ruby 1.8.7.</p>
  
  <p>Why is this happening and how do I do it ?</p>
  
  <pre><code>line = "abc;"
  last_index = line.length-1
  puts "last index = #{last_index}"
  last_char = line[last_index]
  puts last_char
  </code></pre>
  
  <p>Output-</p>
  
  <pre><code>last index = 3
  59
  </code></pre>
  
  <p><a href="http://ruby-doc.org/core-2.0/String.html#method-i-slice">Ruby docs</a> told me that array slicing works this way - </p>
  
  <pre><code>a = "hello there"
  a[1] #=&gt; "e"
  </code></pre>
  
  <p>But, in my code it does not.</p>