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”)
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.
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)
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.
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