C
C#2y ago
noah

❔ Hi so im doing my homework and im supposed to build a function, and i got an error.

9 Replies
Thinker
Thinker2y ago
What happens if Gender1 is "abcdef"?
Servator
Servator2y ago
It expects default return value If not all conditions are met
noah
noahOP2y ago
nothing, names dont change a thing
Servator
Servator2y ago
It should return/throw something
noah
noahOP2y ago
@Samarichitane So what am i supposed to do i tried everything
Servator
Servator2y ago
You should throw an exception or like i said return a default value
hiyosilver
hiyosilver2y ago
They meant that if either of the two strings you pass in is neither "male" nor "female", your function doesn't know what to return because none of your if's covers that case. That's what the compiler doesn't like. You always need to have a path that returns something, so you need to think of some reasonable return value for invalid input or throw an exception like Samarichitane suggested.
noah
noahOP2y ago
ohh alright i get it now i fixed it thank you guys
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server