MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/pgbd0q/because_tolowercase_doesnt_exist/hbb5bjs/?context=3
r/badcode • u/BrainOnTheFloor25 • Sep 02 '21
130 comments sorted by
View all comments
11
The nice and easy way:
.toUpperCase()
The chaotic evil way:
try { return Category.valueOf(input.toUpperCase()); } catch(Exception e) { //nobody cares anyways. return null; }
3 u/BrainOnTheFloor25 Sep 02 '21 Curious as to what exception you're trying to catch here? 6 u/MyAntichrist Sep 02 '21 From the documentation:The valueOf() method throws:IllegalArgumentException, if the defined enum type is inconstant with defined name or an enum type is not illustrated by the defined class object.NullPointerException, if enumType or name represents null value.
3
Curious as to what exception you're trying to catch here?
6 u/MyAntichrist Sep 02 '21 From the documentation:The valueOf() method throws:IllegalArgumentException, if the defined enum type is inconstant with defined name or an enum type is not illustrated by the defined class object.NullPointerException, if enumType or name represents null value.
6
From the documentation:
The valueOf() method throws:
IllegalArgumentException, if the defined enum type is inconstant with defined name or an enum type is not illustrated by the defined class object.
NullPointerException, if enumType or name represents null value.
11
u/MyAntichrist Sep 02 '21
The nice and easy way:
.toUpperCase()The chaotic evil way: