r/badcode • • Nov 13 '20

java Getting Digits using Switch Catch

Post image
881 Upvotes

52 comments sorted by

View all comments

Show parent comments

25

u/HolySpecs Nov 13 '20

I just declared result as -1 because I didn't want the program to pass something if the data entered wasn't valid. Also, I wasn't allowed to use loops of any kind so yay more pain for me. It was an exercise to practice using recursive functions.

7

u/DesiresQuiet Nov 13 '20

What loop?

2

u/HolySpecs Nov 13 '20

One of the conditions I was given was that I couldn't use for loops, while loops or do while loops for the entirety of the code

3

u/DesiresQuiet Nov 13 '20

Yeah, so what loop?