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. Functions

Basic syntax

Function arguments and return types

Argument list

In Snowball, you can define function arguments using the following syntax:

func function_name(name: type) {
    // Function body
}

For example, let's consider a function called hello that takes a single argument x of type i32 (32-bit integer). The syntax for defining such a function with an argument in Snowball would be:

func hello(x: i32, y: f32) {
    // Function body
}

Within the function body, you can access and use the argument x as needed to perform operations or calculations. Remember to provide the appropriate data type when invoking the hello function and passing values for the argument.

Using the syntax mentioned above, you can define functions with different arguments in Snowball, allowing for flexible and modular code development.

Return types

In Snowball, you can specify the return type of a function using the following syntax:

func function_name() return_type {
    // Function body
    // Return statement
}

Using the syntax mentioned above, you can define functions with different return types in Snowball, allowing you to perform computations and provide results based on your program's requirements.

Voided functions

To declare a function as void, there's no need to declare void type, just can not put anything:

func no_returns(a: i32, b: f32) {
    // tada!
}
PreviousFunctionsNextFunction Generics

Last updated 1 year ago

Was this helpful?

🤖
🐣
🎭Types