opIndex vs. opSlice for empty slices

weaselcat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 21 22:49:15 PDT 2015


On Friday, 22 May 2015 at 05:47:28 UTC, Mike Parker wrote:
> I've always used opSlice to produce empty slices, but having 
> recently read the documentation at [1], I see this:
>
> "To overload a[], simply define opIndex with no parameters:"
>
> And no mention that opSlice can fill the same role. Am I right 
> to infer that we should prefer opIndex over opSlice for this? 
> If so, what's the rationale?
>
>
> [1] http://dlang.org/operatoroverloading.html#slice

http://forum.dlang.org/thread/luadir$t0g$1@digitalmars.com#post-luadir:24t0g:241:40digitalmars.com


More information about the Digitalmars-d-learn mailing list