I\'ve seen many instances where |
or &
are used, but I haven\'t understood what they are used for. I know what &&
and ||<
You can read about them and their differences in Swift docs.
Logical Operators 1
Logical operators modify or combine the Boolean logic values true and false. Swift supports the three standard logical operators found in C-based languages:
Logical NOT (!a) Logical AND (a && b) Logical OR (a || b)
Bitwise Operators 2
Bitwise operators enable you to manipulate the individual raw data bits within a data structure. They are often used in low-level programming, such as graphics programming and device driver creation. Bitwise operators can also be useful when you work with raw data from external sources, such as encoding and decoding data for communication over a custom protocol.
Swift supports all of the bitwise operators found in C, as described below.