> How do you define a default value for a function argument whose type is
> a class? I have tried this:
>
> vim9script
>
> class X
> endclass
>
> def F(x: X = null_object)
> enddef
>
> F()
>
> But this results in:
>
> E1013: Argument 1: type mismatch, expected object<X> but got object<Unknown>
>
> Maybe this is not supported yet?
The type system isn't fully worked out yet. This works, but it's not
ideal:
var def: X
def F(x: X = def)
enddef
I'm not sure what syntax we should use for "null object of class X"?
--
Two fish in a tank. One says to the other:
"Do you know how to drive this thing?"
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230312201722.DBBE41C0D07%40moolenaar.net.
Sunday, March 12, 2023
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment