Contract Mastery: Imp Operators

1. & (ampersand)

If an expression starts with the & (ampersand) symbol, it creates a reference.

let a: String = "hello"

let refOfA: &String = &a as &String

2. @ (at)

The @ (at) symbol before a type is used to annotate whether the type is a resource.

pub resource SomeResource {

pub var value: Int

init(value: Int) {

self.value = value

}

}

let a: @SomeResource <- create SomeResource(value: 0)

More operators can be accessed from here