3 ms·
> But it definitely makes code less legible, which makes me cautious. Disagree. In cases where it's useful it can make the code much clearer. Just yesterday I
by kbd 7y ago
> But it definitely makes code less legible, which makes me cautious.
Disagree. In cases where it's useful it can make the code much clearer. Just yesterday I wrote code of the form:
foos = []
foo = func(a,b,c,d)
while foo:
foos.append(foo)
foo = func(a,b,c,d)
With the walrus operator, that would just be:
foos = []
while foo := func(a,b,c,d):
foos.append(foo)
Further, I had to pull out 'func' into a function in the first place so I wouldn't have something complicated repeated twice, so it would remove the need for that function as well.