Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
merthsoft wrote:


And to think, you can replace that whole class with:

Code:
Object[] createArray(Object... values) {
    return values;
}


(Better yet, make it type safe with generics while you're at it)
Oh, the humanity; that's truly horrible. I seriously hope he wrote a program to generate that at least, and didn't spend hours copying and pasting. Sad
Kill it with fire.
souvik1997 wrote:
My friend tried to make a Periodic Table kind of program in science class today and this is what he wrote:

TI Basic:

Code:
Input "ELEMENT:",Str1
If Str1="HYDROGEN"
Disp "ELEMENT PICKED:",Str1
.....


This continued for about 100 more elements of the periodic table. Sad [/code]
Baaaaahahahahhahahahahahaha. Wow. Perhaps what he really should have considered was a non-alphanumeric-delimited list of element names to search, if verifying that the user entered a valid element name was so important?
KermMartian wrote:
souvik1997 wrote:
My friend tried to make a Periodic Table kind of program in science class today and this is what he wrote:

TI Basic:

Code:
Input "ELEMENT:",Str1
If Str1="HYDROGEN"
Disp "ELEMENT PICKED:",Str1
.....


This continued for about 100 more elements of the periodic table. Sad [/code]
Baaaaahahahahhahahahahahaha. Wow. Perhaps what he really should have considered was a non-alphanumeric-delimited list of element names to search, if verifying that the user entered a valid element name was so important?


Huh? I don't get it... Confused
Instead of having one hundred and nineteen If/Disp statements, a single inString() statement and associated Disp. Smile For example:


Code:
:Input "ELEMENT:",Str1
:If inString("HYDROGEN.HELIUM.LITHIUM.BERYLLIUM.BORON.CARBON...:LAURENCIUM",Str1+".
:Then
:Disp "ELEMENT:",Str1
:Else
:Disp "INVALID!
:End
KermMartian wrote:
inString("HYDROGEN.HELIUM.LITHIUM.BERYLLIUM.BORON.CARBON...:LAURENCIUM.",Str1+".

Razz
elfprince13 wrote:
KermMartian wrote:
inString("HYDROGEN.HELIUM.LITHIUM.BERYLLIUM.BORON.CARBON...:LAURENCIUM.",Str1+".

Razz
Yeah, I reminded myself that I needed to type that when I started the string, but by the time I got to the end, I had forgotten. Close enough.
ah, figures, I have not used the inString command before :/
qazz42 wrote:
ah, figures, I have not used the inString command before :/
You'd better take a look at the string manipulation commands then, namely inString(), sub(), and +. There's a lot of fun and powerful things that you can do with them.
I know, but currently pse-rpg does not need them atm
So here's something awesome I came across, we have two functions:
GetSelftAndAncestorCompany
GetSelfAndAncestorCompany
They are exactly the same. Guess which one never gets used?
merthsoft wrote:
So here's something awesome I came across, we have two functions:
GetSelftAndAncestorCompany
GetSelfAndAncestorCompany
They are exactly the same. Guess which one never gets used?
I bet that the one without the typo never gets used! Very Happy
I came across a gem today:

Code:
1.ToString();

Neutral Apparently "1" is not good enough for some people.
From a hunk of Python that dissected ELF files for some reason:

Code:
# I don't always define my C structures in python, but when I do I prefer
# to keep the type definitions in C order.
c_order = lambda fields: [(name, t) for t, name in fields]
XD nice, I love that meme.
Anything from Omnimaga is pretty silly and poorly coded. Does that count?
Kllrnohj wrote:
merthsoft wrote:


And to think, you can replace that whole class with:

Code:
Object[] createArray(Object... values) {
    return values;
}


Actually, according to the comment above the class, the purpose is to reduce the size of bytecode (calling a method takes less bytecode than creating an array). With a varargs method, the Java compiler inserts code into the caller to create the array, which is exactly what they're trying to avoid.
merthsoft wrote:
I came across a gem today:

Code:
1.ToString();

Neutral Apparently "1" is not good enough for some people.
Haha, that seems like some kind of obscure rule that exists in some documentation somewhere, in case a particular language doesn't use arabic numerals, perhaps? Very Happy Maybe I'm just trying to justify poor code.
KermMartian wrote:
Haha, that seems like some kind of obscure rule that exists in some documentation somewhere, in case a particular language doesn't use arabic numerals, perhaps? Very Happy Maybe I'm just trying to justify poor code.


Is the ToString for int's localized?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 5 of 6
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement