3 ms·
After years of Python I can't remember which one of these are correct 1 ",".join(["a", "b"]) 2 ["a", "b"].join(",") 3 ",".split("a,b") 4 "a,b".split(",
by pmontra 5y ago
After years of Python I can't remember which one of these are correct
1 ",".join(["a", "b"])
2 ["a", "b"].join(",")
3 ",".split("a,b")
4 "a,b".split(",")
These method names feel like active form so 1 and 3 should be correct but it's 1 and 4 despite "a,b" obviously is not splitting "," but it's splitted by it
In Ruby it's 2 and 4.
I'm out of luck twice but at least Ruby has a and b always to the left and the comma always to the right so I always remember it.