Skip to content

returning a Final value from a function #1848

Closed Answered by erictraut
Josverl asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think it makes sense to special-case this in the type system.

@Josveri, if you want to use a static type checker with micropython code, my recommendation is to use an explicit Final with the variable declaration.

a: Final = const(b)

This informs a static type checker that the symbol cannot be reassigned, and the const function tells the runtime to enforce this. If you don't want to use a static type checker with your code, you can omit the Final qualifier.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@erictraut
Comment options

Answer selected by Josverl
@Josverl
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants