Type Arguments
fun foo() {
let x = id<bool>(true);
}fun foo() {
let foo = Foo<bool> { x: true };
let Foo<bool> { x } = foo;
}fun foo() {
let x = id<u64>(true); // error! true is not a u64
}Last updated
fun foo() {
let x = id<bool>(true);
}fun foo() {
let foo = Foo<bool> { x: true };
let Foo<bool> { x } = foo;
}fun foo() {
let x = id<u64>(true); // error! true is not a u64
}Last updated
fun foo() {
let foo = Foo<bool> { x: 0 }; // error! 0 is not a bool
let Foo<address> { x } = foo; // error! bool is incompatible with address
}struct Foo<T> {
foo: u64
}module my_addrx::M{
// Currency Specifiers
struct Currency1 {}
struct Currency2 {}
// A generic coin type that can be instantiated using a currency
// specifier type.
// e.g. Coin<Currency1>, Coin<Currency2> etc.
struct Coin<Currency> has store {
value: u64
}
// Write code generically about all currencies
public fun mint_generic<Currency>(value: u64): Coin<Currency> {
Coin { value }
}
// Write code concretely about one currency
public fun mint_concrete(value: u64): Coin<Currency1> {
Coin { value }
}
}