Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

StringBuffer.reverse();

Name: Anonymous 2008-01-14 5:10

public class MainClass {
  public static void main(String args[]) {
    StringBuffer sb1 = new StringBuffer("abcde");
    sb1.append("abcdefghij");
    StringBuffer sb2 = sb1.reverse();
    System.out.println(sb1);
    System.out.println(sb2);
  }
}


Why the fuck is jihgfedcbaedcba also being assigned to sb1?

Name: Anonymous 2008-01-14 10:44

It reverses in place, and then returns a reference to this for no particular reason.
It would be quite nice in the forced indentation of code if you want to iterate through an array backwards.
for i in range(len(a)).reverse()
TOO BAD THE REVERSE METHOD RETURNS NOTHING SO YOU HAVE TO DO SOME STUPID SHIT LIKE range(len(a))[::-1]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List