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

Pages: 1-

Objective C

Name: Anonymous 2014-03-15 2:28

Name: Anonymous 2014-03-15 3:51

Stahp objectifyin' meh!

Name: Anonymous 2014-03-15 5:39

I found this cool feature in Objective C where you can define two different categories that extend the same base class and both implement a method with the same name but with different return types. Which method gets called? What is the type of the return value? Only the ghost of Steve Jobs knows.

Name: Anonymous 2014-03-15 15:51

>>3
You mean it has polymorphism and runtime type info? Big fucking deal.

Name: Anonymous 2014-03-15 21:27

>>3
Is the called function based on how the returned value is being used?

So you could do
int i = func()
and
start s = func()

And the compiler would know which func to use?

Name: Anonymous 2014-03-16 1:52

>>5
∧ junction, what's your function?

Name: Anonymous 2014-03-17 23:39

>>4

If, for example, in Java I do this:


public interface foo {
  public int g();
}


I shouldn't be able to then do this:


public class bar implements foo {
  public String g() {
    return "a string";
  }
}


Because that's retarded. But categories in Objective C aren't polymorphism.

Name: 7 2014-03-17 23:43

Categories work like this instead:


class A {
}

class A_Extension1 category of A {
  // all instances of A now have this method
  public int foo() {
    return 4;
  }
}

class A_Extension2 category of A {
  // we already declared this, but Objective C lets that slide
  public String foo() {
    return "a string";
  }
}

A a = new A();
a.foo(); // which method gets called?

Name: 7,8 2014-03-17 23:46

I gave examples in "Java" instead of Objective C as it emphasizes how retarded it is.

Name: Anonymous 2014-03-22 11:09

objective c a shit

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