Update Item Specifications
parent
72871df709
commit
cfe1576dd4
1 changed files with 1 additions and 1 deletions
|
@ -37,7 +37,7 @@ Note the above implementation of square works for all types, so there is not any
|
|||
```
|
||||
export const multiply = onType([Number, Number], Returns(Number, (a, b) => a * b))
|
||||
```
|
||||
Here, onType creates one or more "patterns" (an array of types to match against the actual arguments) with associated behaviors, which can be exported to produce implementations for a method that will be dispatched when the arguments match the pattern. The fact that the behavior is return-type-labeled indicates that the item has no dependencies.
|
||||
Here, onType creates an "Implementation," which consists of one or more "type patterns" (an array of types/type predicates to match against the actual arguments) with associated behaviors, which can be exported to produce partial definitions for a method: a behavior will be executed when the argument types match its associated pattern. The fact that here the behavior is return-type-labeled indicates that the item has no dependencies. There is a separate page devoted to the details of [implementations and type patterns](Implementations-and-Type-Patterns).
|
||||
|
||||
Next, let's look at a method like addition of two complex numbers that accepts many types (any instantiation of Complex) but not all types, and has dependencies:
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue