GetFortCharacter[]? GetFortCharacter()?

I read in the documentation that GetFortCharacter is a method. However, when calling and using GetFortCharacter, it said that square brackets are needed like GetFortCharacter. Why are the square brackets necessary? If it’s a method, it should be like GetFortCharacter(), which is common in other programming languages, right?

I’m new to verse but as i understand it, square brackets for a function call indicate that it can fail and therefore should be contained within an “if” statement (to handle any failure that may occur)

1 Like

KeyserScholze is correct. It is a method, but it is also a “failable expression,” and Verse requires that failable expressions be called conditionally (usually with an IF or FOR expression) and square brackets must be used. Coincidentally, in Verse, calling arrays are also failable expressions and are called conditionally with brackets as well. Since an array might not return a value, it can fail and is allowed to fail, but in what they call a failure context. While Verse has many similarities to other programming languages, it is also unique in many ways and has many guardrails to prevent runtime errors.

4 Likes

I didn’t realize the syntax was needed for when the function fails. Thank you for your help.

1 Like

Thank you very much for explaining in such detail. The Verse programming language is difficult, but I want to learn it step by step.