Methods.rb issue with last_digit(int)

def last_digit(int)
int.to_s[-1].to_i
end

Does not work

but
def last_digit(int)
return int.to_s[-1].to_i
end
Does. I am not certain why this is. Could someone explain it to me?

Edit: What this code does is takes the initial argument which we can assume to be an integer and turns it into a string with the “.to_s” method. I then index into the strings last value with “[-1]” at which point i call “.to_i” to turn the value back into an integer to satisfy the rspec clause which expects the response to be an int.
My code without the " return" - returns nil and I am not sure why this is the case.

I um. Failed to reproduce the bad results a third time so umm. . . I have no idea why it didn’t work but it totally should so. Nevermind.