I have this:
sentence.each_char {|char|
   ......
   ......
}
I want this:
sentence.each_char {|char|
   if (char is the last char)
     ......
   end
}
Does anybody know how I can do that?
length = sentence.length
sentence.each_char.with_index(1){|char, i|
  if i == length
    ...
  end
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With