9 Replies
What happens if
Gender1
is "abcdef"
?It expects default return value
If not all conditions are met
nothing, names dont change a thing
It should return/throw something
@Samarichitane So what am i supposed to do i tried everything
You should throw an exception or like i said return a default value
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.
ohh alright i get it now
i fixed it
thank you guys
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.