ModularM
Modular3y ago
1 reply
Xcur

Alias does not work with raises String methods

I have a string i know at compile time and I was writing a function to split it into each of the new lines, but because split has a raises flag it cannot be run at compile time and stored as an alias. I noticed there is a TODO to allow this, and im curious when will alias work with potentially raising functions?

Here is my sample code:
alias string: String = \
"""Hello World
Hello World
Hello World"""

# does not work due to raises flag
alias lines = string.split("\n")

fn main() raises:
    # uncomment and this works
    # let lines = string.split("\n")

    for i in range(len(lines)):
        print(lines[i])
Was this page helpful?