Reverse the gender of a string: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example... against my better judgement.) |
|||
Line 137: | Line 137: | ||
His dog belongs to her but her dog is his! |
His dog belongs to her but her dog is his! |
||
</pre> |
</pre> |
||
=={{header|Objeck}}== |
|||
{{trans|Java}} |
|||
<lang objeck>class ReallyLameTranslationOfJ { |
|||
function : Main(args : String[]) ~ Nil { |
|||
s := "She was a soul stripper. She took my heart!"; |
|||
CheapTrick(s)->PrintLine(); |
|||
CheapTrick(CheapTrick(s))->PrintLine(); |
|||
} |
|||
function : CheapTrick(s : String) ~ String { |
|||
if(s->Find("She") > -1) { |
|||
return s->ReplaceAll("She", "He"); |
|||
} |
|||
else if(s->Find("He") > -1) { |
|||
return s->ReplaceAll("He", "She"); |
|||
}; |
|||
return s; |
|||
} |
|||
} |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
He was a soul stripper. He took my heart! |
|||
She was a soul stripper. She took my heart! |
|||
</pre> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |