Skip to content

Commit

Permalink
note infix syntax for "in" and "∈" (#54091)
Browse files Browse the repository at this point in the history
I noticed that the docstring for `in` did not mention the infix syntax
up-front, making it easier to [be confused about the argument
order](https://discourse.julialang.org/t/in-x-y-and-y-in-x-behave-differently/112965).
  • Loading branch information
stevengj committed Apr 20, 2024
1 parent fda02ac commit 033abb4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1382,11 +1382,15 @@ a function equivalent to `y -> item in y`.
Determine whether an item is in the given collection, in the sense that it is
[`==`](@ref) to one of the values generated by iterating over the collection.
Can equivalently be used with infix syntax:
item in collection
item ∈ collection
Return a `Bool` value, except if `item` is [`missing`](@ref) or `collection`
contains `missing` but not `item`, in which case `missing` is returned
([three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic),
matching the behavior of [`any`](@ref) and [`==`](@ref)).
Some collections follow a slightly different definition. For example,
[`Set`](@ref)s check whether the item [`isequal`](@ref) to one of the elements;
[`Dict`](@ref)s look for `key=>value` pairs, and the `key` is compared using
Expand Down

0 comments on commit 033abb4

Please sign in to comment.