Skip to main content
Tweeted twitter.com/#!/StackCodeReview/status/488514788973346817
added 1 character in body; edited tags
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

I have created the following code:

def LetterCapitalize(str)
  str = str.split(" ").each {|word| word.capitalize!}
  str = str.join(" ")
  return str
end

This takes in a basic string and capitalizes the first letter of all of the words. It looks kind of awkward to reassign things to "str"str twice. What is wrong with my style here, if anything at all?

I have created the following code:

def LetterCapitalize(str)
  str = str.split(" ").each {|word| word.capitalize!}
  str = str.join(" ")
  return str
end

This takes in a basic string and capitalizes the first letter of all of the words. It looks kind of awkward to reassign things to "str" twice. What is wrong with my style here if anything at all?

I have created the following code:

def LetterCapitalize(str)
  str = str.split(" ").each {|word| word.capitalize!}
  str = str.join(" ")
  return str
end

This takes in a basic string and capitalizes the first letter of all of the words. It looks kind of awkward to reassign things to str twice. What is wrong with my style here, if anything at all?

Source Link
user2801122
  • 365
  • 1
  • 4
  • 7

Capitalize all words in sentence string in Ruby

I have created the following code:

def LetterCapitalize(str)
  str = str.split(" ").each {|word| word.capitalize!}
  str = str.join(" ")
  return str
end

This takes in a basic string and capitalizes the first letter of all of the words. It looks kind of awkward to reassign things to "str" twice. What is wrong with my style here if anything at all?