Hash Compare
Johnny
bierbauch at jenz.info
Wed Apr 18 10:39:05 PDT 2007
BCS Wrote:
> Johnny wrote:
> > BCS Wrote:
> >>Johnny wrote:
> >>
> >>>foreach (m; a.keys) {
> >>> if ( b[m] ) {
> >>> writefln("%s %s %s", m, a[m], b[m])
> >>> }
> >>> else {
> >>> writefln("%s %s", m, a[m])
> >>> }
> >>>}
> >>
> >>foreach (k, v1; a) {
> >> if ( auto v2 = k in b ) // is this what your looking for?
> >> writefln("%s %s %s", k, v1, *v2)
> >> else
> >> writefln("%s %s", k, v1)
> >>}
> >
> > A good hint. my problem is that I get an ArrayBounds error if i try it with my method.
> > ... an I can't catch it
>
> The "/a/ in /b/" construct fixes that. Just looking up the value should
> do what you described if the value isn't their.
I've tested it, and yes thank you very much it works fine!
.. but still don't really understand what "auto v2 = m in b" means
something like v2 = b.keys ?
More information about the Digitalmars-d-learn
mailing list