Method to find firsty letter of word?

heres the method,

def start_of_word(word,x)
letter = word[0,x]
letter
end

word[0,x]
confused me but I think its creating an array, word and puts in it (starting at position/index 0) x letters, is this right?

Almost.

letter = word[0,x]

Here the variable letter is a string, which is assigned characters 0 - x of the string “word”.

FWIW the value of the final expression evaluated in a method is the return value in ruby, so you could also write:

def start_of_word(word,x)
  word[0,x]
end

ok, thanks again