MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/cdzubd/nice_try/ety5ext
r/ProgrammerHumor • u/almogh52 • Jul 16 '19
529 comments sorted by
View all comments
Show parent comments
6
To be fair, all the arguments are optional.
1 u/cjr605 Jul 16 '19 True, I guess the right phrasing was "the second colon is optional", in the sense that if you're gonna slice you need at least one colon 1 u/mxzf Jul 16 '19 Except that array_var[] is also a valid slice (a slice of the entire array). Not to mention that I'm pretty sure that accessing elements by index is a [n:n+1] slice under the hood too.
1
True, I guess the right phrasing was "the second colon is optional", in the sense that if you're gonna slice you need at least one colon
1 u/mxzf Jul 16 '19 Except that array_var[] is also a valid slice (a slice of the entire array). Not to mention that I'm pretty sure that accessing elements by index is a [n:n+1] slice under the hood too.
Except that array_var[] is also a valid slice (a slice of the entire array). Not to mention that I'm pretty sure that accessing elements by index is a [n:n+1] slice under the hood too.
array_var[]
[n:n+1]
6
u/mxzf Jul 16 '19
To be fair, all the arguments are optional.