Jump to content

Reverse the gender of a string: Difference between revisions

(→‎{{header|Perl 6}}: Add a Perl 6 example... against my better judgement.)
Line 137:
His dog belongs to her but her dog is his!
</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}}==
760

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.