Can function parameters be specified to accept eit...
# getting-started
m
Can function parameters be specified to accept either of two types? My use case is functions accepting either a ResourceStringDesc or ResourceFormattedStringDesc (from Moko Resources).
Thanks for that. Writing different types is a pain in this situation, I'm passing errors up a chain of calling, so there are several "double function" definitions required, which is very tedious. ๐Ÿ˜ž
Yes, fully under my control. Ok, I'll have to look up sealed classes
๐Ÿ™ 1
๐Ÿ‘ 2
w
m
Trying to, but it looks like a YouTrack account is different from a JetBrains account, or at least my JB account details don't let me log in to YouTrack. ๐Ÿ˜ž
The "double function" solution is also really annoying when both functions are exactly the same except for the parameter type. Both ResourceStringDesc and ResourceFormattedStringDesc use the same name method to produce a string. ๐Ÿค”๐Ÿ˜ž
w
They sound like they are really good candidates to be expressed as a sealed type ๐Ÿ™‚
โ˜๏ธ 1
m
Falls foul of the "single module" restriction I think. I'm not clear what "indirect sealed types" are, which seem to make that restriction go away.
s
Why not use an interface?
โž• 3
m
I'm not sure how that would help @sciack. I still have to have double definitions in the interface, don't I?