If “hello” * 4 = “hellohellohellohello”, why doesn’t “x,y,z” / “,” = [“x”, “y”, “z”]?
-
Show this thread
-
Ruby? Hello? I’m asking!
3 replies 2 retweets 10 likesShow this thread
Replying to @tqbf
class MyStr(str): def __sub__(self, other): if self[-len(other):] == other: return self[:-len(other)] raise ValueError(self + " does not end with " + other) print(MyStr("abcdef") - "ef") # "abcd" print(MyStr("abcdef") - "de") # exception
4:54 PM - 9 Jan 2018
0 replies
0 retweets
2 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.