Re: In what order are dict values returned by "dict get"?
- From: "Donal K. Fellows" <donal.k.fellows@xxxxxxxxx>
- Date: 4 Dec 2006 08:44:09 -0800
Adrian Davis wrote:
In what order are dict values returned by "dict get?"
I think you must mean [dict keys] or [dict values] there; [dict get]
itself only returns a single value.
Are they in apha order by keyname or is it random?
Officially random. Unofficially, it depends on a whole bunch of factors
including the history of the hash that backs the implementation. It's
quite difficult to characterize.
What you *can* be assured of is that:
foreach key [dict keys $d] val [dict values $d] {
puts "$key -> $val"
}
will print out matched pairs of values. What you can't be assured of is
what order they'll be in, other than that you'll get the same effect
from this:
foreach {key val} $d {
puts "$key -> $val"
}
Donal.
.
- References:
- In what order are dict values returned by "dict get"?
- From: Adrian Davis
- In what order are dict values returned by "dict get"?
- Prev by Date: TclPro for Fedora now available
- Next by Date: Re: works in tclsh but fails in CGI
- Previous by thread: Re: In what order are dict values returned by "dict get"?
- Next by thread: ActiveTCL - which executable should I use?
- Index(es):
Relevant Pages
|