Verse Library verse

03 Implicit Type Arguments

Defines a generic class with two type parameters and a factory function to instantiate it with various types.

extracted-snippets/documentation/en-us/uefn/parametric-types-in-verse/03-implicit-type-arguments.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/parametric-types-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/parametric-types-in-verse.md
# Section:    Implicit Type Arguments
box(first_item:type, second_item:type) := class:
    ItemOne:first_item
    ItemTwo:second_item

MakeBox(ItemOneVal:ValOne, SecondItemVal:ValTwo where ValOne:type, ValTwo:type):box(ValOne, ValTwo) =
    box(ValOne, ValTwo){ItemOne := ItemOneVal, ItemTwo := SecondItemVal}

Main():void =
    MakeBox("A", "B")
    MakeBox(1, "B")
    MakeBox("A", 2) 
    MakeBox(1, 2)
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in