VerseWiki
VerseWiki
  • Table of Contents
  • Import Expressions
  • 01. Common Naming Patterns
  • 02. Names
  • 03. Formatting
  • 04. Functions
  • 05. Failure Checks
  • 06. Encapsulation
  • 07. Events
  • 08. Concurrency
  • 09. Attributes
  • 10. Constructors
  • 11. Class & Specifiers
  • 12. Math
  • 13. Containers
  • 📘Fortnite Digest
  • 📗Unreal Engine Digest
  • 📕Verse Digest
  • EG: Onboarding Guide
  • EG: Verse Programming
  • EG: Language Reference
  • EG: Official API
  • EG: Verse Scripting
  • EG: Dev Community
  • EG: Community Snippets
  • View on Github Wiki
Powered by GitBook
On this page
  • Option
  • Initialization

Was this helpful?

13. Containers

Store multiple values together by using a container . Verse has a number of container types to store values in.

Option

  • The option type can contain one value or can be empty.

  • In the following example, MaybeANumber is an optional integer ?int that contains no value, A new value for MaybeANumber is then set to 42.

var MaybeANumber : ?int = false # unset optional value
set MaybeANumber := option{42} # assigned the value 42

Initialization

You can initialize an option with one of the following:

  • No value: Assign false to the option to mark it as unset.

  • Initial value: Use the keyword option followed by {}, and an expression between the {}. If the expression fails, the option will be unset and have the value false.

  • Specify the type by adding ? before the type of value expected to be stored in the option. For example ?int.

MaybeANumber : ?int = option{42} # initialized as 42
 
MaybeAnotherNumber : ?int = false # unset optional value
Previous12. MathNextFortnite Digest

Last updated 1 year ago

Was this helpful?