Snowball Docs
SocialsContributeTry out online!Standard Library
  • 👋Welcome to snowball!
  • Overview
    • 🐈Why Snowball
    • ✨Language Features
  • fundamentals
    • 🛠️Getting started
    • 📝Installation
      • ‼️Common install issues
    • 👶Hello world!
  • language reference
    • 🌐Global Scope
    • 🤖Functions
      • 🐣Basic syntax
      • 😵Function Generics
      • ❓External functions
      • 🔧Function Attributes
      • 💢LLVM Functions
      • 🚪Program Entries
    • 🎭Types
      • 🔢Primitive types
      • 🔀Reference types
      • ☝️Pointer types
      • 🔓Mutability
      • ⁉️Type generics
      • 🔖Type aliases
      • 🚯Unknown pointer type (void pointers)
    • 🔄Casting
      • 🔐Mutability casting
      • 🦺Dynamic casting
      • 👨‍🎓Type conversions
    • 🏗️Classes
      • 💼Members
      • 🔒Access qualifiers
      • 🛑Final classes
      • 🍧Abstract classes
    • 🔏Access qualifiers
    • ⚒️Macros
      • ✨Builtin macros
    • 🔫Unsafe snowball
    • 😴Generics
    • 🌳Code Flow
      • ☝️If statements
    • 📦Modules
      • 👉Using Statement
  • snowball cli usage
    • 💻CLI usage and parameters
    • 🧪Testing mode
  • Confy
    • ⚙️Getting Started
    • 🐈Snowball's Schema
  • Reky Package Manager
    • 📦Getting Started
  • coding style
    • 💅The desired standard
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. language reference
  2. Types

Type generics

In Snowball, type generics enable you to write reusable code that can operate on different types. They allow you to create functions, data structures, and components that can adapt to various data types without sacrificing type safety. Type generics in Snowball are denoted by <...> and provide flexibility and versatility in your code. Here's how type generics are used in Snowball:

let a: Vector<i32>;
  • In this example we are pointing to a vector type that has the first generic argument as i32.

Using type generics inside expressions.

Generic types can be defined using < ... > in places where snowball expects a type. But in other places such as in function arguments, we would need to provide an extra ? symbol to differentiate the expression from being a less than operator.

let a = myFunction<?i32>();
PreviousMutabilityNextType aliases

Last updated 1 year ago

Was this helpful?

🎭
⁉️