Skip to content

Commit

Permalink
added docs and test for issue JuliaLang#18090
Browse files Browse the repository at this point in the history
  • Loading branch information
Marne, Prasad committed Jan 24, 2017
1 parent 75302ae commit 862202b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/associative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ in(k, v::KeyIterator) = get(v.dict, k, secret_table_token) !== secret_table_toke
keys(a::Associative)
Return an iterator over all keys in a collection.
`keys(Dict)` and `values(Dict)` both simply iterate the `Dict`
and return the elements in the same order.
`collect(keys(d))` returns an array of keys.
Since the keys are stored internally in a hash table,
the order in which they are returned may vary.
Expand All @@ -87,6 +89,8 @@ eachindex(a::Associative) = KeyIterator(a)
values(a::Associative)
Return an iterator over all values in a collection.
`keys(Dict)` and `values(Dict)` both simply iterate the `Dict`
and return the elements in the same order.
`collect(values(d))` returns an array of values.
```jldoctest
Expand Down
9 changes: 9 additions & 0 deletions test/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,12 @@ end
@test f.x[2].first == (-, 6, 5, 3, 5, 8)
@test f.x[2].second == 1
end

# issue #18090
let
d = Dict(i => i^2 for i in 1:10_000)
z = zip(keys(d), values(d))
for (pair, tupl) in zip(d, z)
@test pair[1] == tupl[1] && pair[2] == tupl[2]
end
end

0 comments on commit 862202b

Please sign in to comment.