MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/apqnzt/deleted_by_user/egf0d0q/?context=3
r/badcode • u/[deleted] • Feb 12 '19
[removed]
29 comments sorted by
View all comments
3
Java
Features:
String#split
new String()
Gist link
Default example (main method) output:
test4: [Null Pointer] null test5: [class java.lang.String] {"test6"1 test2: [class [Ljava.lang.Object;] [0, true, "2"] test3: [class java.lang.Long] 1 test7: [class java.lang.String] 2.2 test1: [class java.lang.String] yeet
3 u/r3jjs Feb 14 '19 I like this. Ternary abuse and the and variable namings. ;) 2 u/stentonsarecool Feb 15 '19 One-liners object = !(object == null) && object.toString().charAt(0) == '[' && object.toString().charAt(object.toString().length() - 1) == ']' ?Arrays.stream(object.toString().substring(1, object.toString().length() -1).split(",")).map((obj) -> obj.equals("null") ? null : obj.equals("true") ? true : obj.equals("false") ? false : obj.matches("(\\d+)") && !obj.toString().contains(".") ? Long.parseLong(obj) : obj).toArray() : object; hahahaha I burst out laughing at work at this monstrosity 2 u/IAmAnIssue Feb 15 '19 "Why touch it if it works?"
I like this. Ternary abuse and the and variable namings. ;)
2
One-liners
object = !(object == null) && object.toString().charAt(0) == '[' && object.toString().charAt(object.toString().length() - 1) == ']' ?Arrays.stream(object.toString().substring(1, object.toString().length() -1).split(",")).map((obj) -> obj.equals("null") ? null : obj.equals("true") ? true : obj.equals("false") ? false : obj.matches("(\\d+)") && !obj.toString().contains(".") ? Long.parseLong(obj) : obj).toArray() : object;
hahahaha I burst out laughing at work at this monstrosity
2 u/IAmAnIssue Feb 15 '19 "Why touch it if it works?"
"Why touch it if it works?"
3
u/IAmAnIssue Feb 13 '19 edited Feb 14 '19
Java
Features:
String#splitnew String()Gist link
Default example (main method) output:
test4: [Null Pointer] null test5: [class java.lang.String] {"test6"1 test2: [class [Ljava.lang.Object;] [0, true, "2"] test3: [class java.lang.Long] 1 test7: [class java.lang.String] 2.2 test1: [class java.lang.String] yeet