declare a type constraint.
type Number interface { int64 | float64
}
If you want to change selection, open document below and click on "Move attachment"
Tutorial: Getting started with generics - The Go Programming Languagehods. Constraint interfaces can also refer to specific types, as you’ll see in this section. Write the code Just above main, immediately after the import statements, paste the following code to <span>declare a type constraint. type Number interface { int64 | float64 } In this code, you: Declare the Number interface type to use as a type constraint. Declare a union of int64 and float64 inside the interface. Essentially, you’re moving the union from th Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details