September 13, 2011 Re: defining "in" What is the proper way in D2? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Hixson | On Mon, 12 Sep 2011 00:00:55 +0300, Charles Hixson <charleshixsn@earthlink.net> wrote: > On 09/11/2011 01:25 PM, Vladimir Panteleev wrote: >> On Sun, 11 Sep 2011 23:02:37 +0300, Charles Hixson >> <charleshixsn@earthlink.net> wrote: >> >>> I can't figure it out from >>> http://www.digitalmars.com/d/2.0/operatoroverloading.html#Binary >> >> // I assume your data structure looks like this >> class Node(Key, Data) >> { >> Key k; >> Node!(Key, Data) left, right; >> int level; >> // ... >> >> void opBinary!("in")(Key k) >> { >> if (level == 0) return false; >> if (k < key) return k in left; >> if (key < k) return k in right; >> return true; >> } >> } > > VOID?? I'm going to presume that this should have been bool. > Otherwise, thanks. That was they syntax I couldn't figure out from the docs. Sorry. Shouldn't have tried this while tired. -- Best regards, Vladimir mailto:vladimir@thecybershadow.net |
Copyright © 1999-2021 by the D Language Foundation