4 ms·
It is problematic for readability reasons as long as you are making complex expressions: configuration := NewConfiguration() configuration[word] = para
by sacado2 8y ago
It is problematic for readability reasons as long as you are making complex expressions:
configuration := NewConfiguration()
configuration[word] = parameters[values[line][column]] - parameters[values[column][line]]
vs
conf := NewConfig()
conf[w] = params[vals[i][j]] - params[vals[j][i]]
It takes your brain more time to parse the first line. Now, there is an obvious limit, this is probably too much
c[w] = p[v[i][j]] - p[v[j][i]]
unless maybe the scope of the vars is very limited.
- Casperin 8y agoThe first version was too long to fit on the screen for me. Reading the second I missed the swapping of `i` and `j` -- only noticing it when I went back to the first version to figure out which parts of line I would assign to something if I were to rewrite the code.
- dagw 8y agoIn your example I would compromise with: conf[w] = params[vals[line][column]] - params[vals[column][line]] or even: conf[w] = params[vals[l][c]] - params[vals[c][l]] if you really want to save a couple of characters. Confusing which loop index is indexing which dimension is far too easy.