set default value of parameter to other parameter [Answered]
ok, i am aware that this is probably not possible, but can i set default value of parameter x to value of parameter y?
consider this example:
would this be possible?
11 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
There could absolutely be cases in which that makes sense. You can do that at the beginning of the method and use a sentinel value for the default argument value
Or null, since it's a string
i started doing some library that generates some sql from json and i want the user to be able to say that column names are not the same as json fields, i know i can do it with overload, but i wanted to know if it is possible like this, mostly out of curiosity
ok thats interesting approach, but at this point i think that it is easier to do it like this:
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yep, both can be used exactly the same ways, though the first would be more DRY to document imo
Irrelevant if you aren't adding XML docs
oh i am probably
I'd definitely opt for my initial chunk of code there. It'll be half the typing to document
ok anyways, thanks for help, i am going to close this thread
!close
✅ This post has been marked as answered!