Examples · learn/05-structs · 110 of 339
struct
A struct type: a name for a group of named fields.
tin run examples/learn/05-structs/struct.tin// A struct type: a name for a group of named fields.
type Book = { title: string, author: string, pages: int }
fn main() {
let book = Book { title: "Dune", author: "Frank Herbert", pages: 412 }
print(book.title)
print("{book.title} has {book.pages} pages")
print(book) // every value can be printed
}