|
|
|
|
|
by parennoob
3752 days ago
|
|
As I said, until it hits some kind of edge case. Again, I'm not trying very hard here, but this oneliner doesn't give the expected output if your sentence has a string like "æsir". irb> @sentence = "\u00e6sir are gods"
=> "æsir are gods"
irb> @sentence = @sentence.split(' ').map!{|x| x = x[0..0].upcase << x[1..-1]}.join(' ')
=> "æsir Are Gods"
(Expected output being "Æsir Are Gods")If you want to understand why this is failing, the code I gave above will make it way simpler. Of course, viewpoints differ – you might claim that troubleshooting it is only a job for "professionals". |
|