Timeline for Transfer the format of an old string to a new string
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 16, 2014 at 12:55 | comment | added | Flambino |
@Starkers It's just an assignment with a ternary, i.e. if...else written in one line. You can spell it out in Ruby as string[i] = (if char == char.upcase then string[i].upcase else string[i].downcase end) .
|
|
Apr 16, 2014 at 11:39 | comment | added | Starkers | @Flambino could you explain the 5th line please? ` string[i] = char == char.upcase ? string[i].upcase : string[i].downcase` Literally all of it. I've got a good idea but I'd want some validation :) | |
Apr 16, 2014 at 11:36 | history | edited | Flambino | CC BY-SA 3.0 |
added 8 characters in body
|
Apr 16, 2014 at 11:29 | history | edited | Flambino | CC BY-SA 3.0 |
added 734 characters in body
|
Apr 16, 2014 at 11:22 | comment | added | Flambino | @200_success As would I. But as far as I can tell from OP's code, case isn't preserved for the "leftover" string... Regardless, you're right; it's unexpected. I'll add a note - thanks | |
Apr 16, 2014 at 9:56 | comment | added | 200_success |
I'd expect the part of the string that extends beyond the end of template to have its case preserved, not forcibly downcased.
|
|
Apr 16, 2014 at 9:28 | history | edited | Flambino | CC BY-SA 3.0 |
added 53 characters in body
|
Apr 16, 2014 at 7:21 | history | answered | Flambino | CC BY-SA 3.0 |