104 - Using for
The directive using A for B
; can be used to attach library functions (from the library A
) to any type (B
) in the context of a contract. These functions will receive the object they are called on as their first parameter.
-
The
using A for B
; directive is active only within the current contract, including within all of its functions, and has no effect outside of the contract in which it is used. -
The directive may only be used inside a contract, not inside any of its functions.
- Directive using A for B
- Attach Functions
- Library A -> Type B
- Object -> First Parameter
- Only Inside Contract
- E.g.: using SafeMath for uint256;