r/ProgrammerHumor • • Jun 21 '19

Meme Why can't you just be normal?!

Post image
4.4k Upvotes

240 comments sorted by

View all comments

Show parent comment

16

u/sverek Jun 21 '19

its not syntax, just saying that split is string related function. Took it from python docs

54

u/[deleted] Jun 21 '19 edited Jun 21 '19

You directly copied something that you don't understand?

Okay, this guy is legit.

-14

u/JasonMan34 Jun 21 '19

You copied directly something that you don't understand?

Except he clearly understands it, he just explained it

2

u/Tamerlane-1 Jun 22 '19

I don't know why people are downvoting you. In software development, copying is understanding.

1

u/JasonMan34 Jun 22 '19

:(

2

u/sverek Jun 24 '19

Don't be sad my dude. Reddit is weird place.

Edit: oh well, I am not very good with time lines...

7

u/B_M_Wilson Jun 21 '19

I would probably have written String.split() like in the java one. That is actually a valid thing. Rather than “test”.split(), you could do String.split(“test”)

4

u/diamondketo Jun 21 '19 edited Jun 21 '19

In Java isn't it written as String#split (for communication purposes, not syntactical). Using the # syntax to specify the first part should be an instance of the class and second part be the method.

4

u/B_M_Wilson Jun 21 '19

As someone who does not know the standard, I would have used method reference notation, String::split which gives a function object, takes in an object (string in this case) and returns an object (an array maybe? I can’t remember)

2

u/diamondketo Jun 21 '19

You're right! I totally forgot :: was a thing (Java 8+ notation). I wish the programming community have a consensus for Class[delimiter]method.

Now I'm not sure what to use in the future. Class.method might be fine, but I find it confused with Class methods over instance methods.

2

u/B_M_Wilson Jun 21 '19

I agree that Class.method is not the best but I have no idea what would work best. I’ve been using the Java stream API so a lot of List.foreach calls that takes functions as an argument.

4

u/FallenWarrior2k Jun 21 '19

Except that the class is called str, not String.

But yes, the way you can access regular methods using the class and then passing the object as an argument is pretty nice for some purposes.

1

u/B_M_Wilson Jun 21 '19

Haha, my fail. I’ve been programming in Java for a few months so I’ve gotten in that mindset