'Expected declaration' error

#1

I cannot call methods that I’ve just written in my class in playgrounds. I am trying to call the evaluate method just like in page 246, but the compiler gives me error 'Expected declaration". I’m calling the method in the same class (Lexer), but apparently I can’t call any of the methods I’ve just written. I can call the method inside other functions, but not outside of them(just inside the class. Am I just missing something simple and silly?

#2

I had the same problem, from what I could tell it was a synctactic issue for me. You can’t easily tell the func evaluate is outside the class, since it’s creating an instance of the Lexer class “lexer”, that’s the hint to move it outside the class definition. Then call evaluate after you’ve defined that function.