-
What's not working? # create my hello decorator
fn my_hello_decorator(func):
fn wrapper():
print("Hello,")
func()
print("Bye Bye!")
return wrapper
# use my hello decorator
@my_hello_decorator
fn print_name():
print("my name is Mark")
print_name() The output should be: Debug: error: Expression [5]:10:12: 'fn() capturing -> None' value cannot be converted to 'None' in return value |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The error message is solved by giving the function correct types: fn my_hello_decorator(func: fn() -> None) -> fn() capturing -> None:
fn wrapper():
print("Hello,")
func()
print("Bye Bye!")
return wrapper
@my_hello_decorator
fn print_name():
print("my name is Mark")
print_name() mojo does not yet support custom decorators though, so it will just print
|
Beta Was this translation helpful? Give feedback.
-
Thanks @DayDun for this answer! 🔥 |
Beta Was this translation helpful? Give feedback.
The error message is solved by giving the function correct types:
mojo does not yet support custom decorators though, so it will just print