Skip to main content

Silly Mistakes (Technically?)

There could be too many, I am listing few of them.
Of course, they are not as obvious as shown below, especially when they go multiple levels of method/function calls.

Split: (Java)

I should have read the docs properly.
Code:

String[] data = { "Phil;45678910;", "Alex;45678910;45678911"};
for(int i=0; i< datasplit =" data[i].split(" i="0;" datasplit =" data[i].split(">



Parse Int: (JavaScript)

Strange? The date component doesn't work properly for August and September. (
I used parseInt(monthField).
Code:

alert(parseInt("07")); // 7
alert(parseInt("08")); // 0
alert(parseInt("0xA")); //10

Thank God, I know number systems!

Key Words: (JavaScript)

The following script throws an error. Absolutely correct?
Code:

var ZDBExport = function()
{
this.export = function(arg1, arg2)
{
// do export
}
}

And realised "export" is a keyword in javascript. It allows the signed script to export its properties to other signed/unsigned script.

Variable Scope: (JavaScript)

I was astonished (because I have not seen this idea anywhere else) javascript variable doesn't have block level scope.

String Array: (JavaScript)
Code:

var myArray = "Dream";
alert(myArray[0]); // IE -> undefined, FF -> D

Simple: substring helps!

Long (Java)

It worked when I had constant values. I forgot to check when I changed that to dynamically created values.

Code:

public static void main(String args[])
{
Long v1 = new Long(20);
Long v2 = new Long(20);

System.out.println(isEqual(20L,20L)); // true
System.out.println(isEqual(v1, v2)); // false
}

public static boolean isEqual(Long val1, Long val2)
{
if(val1 == val2) { return true;}
else { return false; }
}

I understand, symbol tables studied in the college helps!

Looping without Loop

Not a mistake! I think it is beautiful (
Code:

public boolean isType(long typeID, String value)
{
/// return boolean_value
}

public long getType(String value)
{
if(isType(1L,value))
{
return 1;
}
else if (isType(2L, value))
{
return 2;
}
else if ...
}


Switch - Ternary

Not a mistake. I love it.
Code:

switch(value ? no1 : no2)
{
case ....
}


PS: None of the above are actual and I have taken them to show the idea.




Kovil Pillai P.

Comments

Popular posts from this blog

Movie List 2013

List of movies I hear about in year 2013 MovieList2013 S.No. Title Rating Language Link 1 Musa, The Warrior 65 Korean http://www.imdb.com/title/tt0275083/ 2 Endukante... Premanta! 35 Telugu http://en.wikipedia.org/wiki/Endukante..._Premanta! 3 Modern Times 60 English http://www.imdb.com/title/tt0027977/ 4 Scent Of A Woman 70 English http://www.imdb.com/title/tt0105323/ 5 Kozhi Kuvuthu 20 Tamil   6 Seven Samurai 50 English http://www.imdb.com/title/tt0047478/ 7 Aalayamani 60 Tamil http://en.wikipedia.org/wiki/Aalayamani 8 Unnale Unnale 35 Tamil http://en.wikipedia.org/wiki/Unnale_Unnale 9 Alex Pandiyan 25 Tamil http://en.wikipedia.org/wiki/Alex_Pandian 10 Payyans 30 Malayalam http://www.nowrunning.com/movie/7709/malayalam/payyans/index.htm 11 Nadodigal 35 Tamil   12 Searching for Sugar Man  60 English http://www.imdb.com/title/tt2125608/ 13 Hitlist 15 Malayalam http://www.nowrunning.com/movie/109...

Stop & Listen

Source: Email forward A man sat at a metro station in Washington DC and started to play the violin; it was a cold January morning. He played six Bach pieces for about 45 minutes. During that time, since it was rush hour, it was calculated that thousand of people went through the station, most of them on their way to work. Three minutes went by and a middle aged man noticed there was musician playing. He slowed his pace and stopped for a few seconds and then hurried up to meet his schedule. A minute later, the violinist received his first dollar tip: a woman threw the money in the till and without stopping continued to walk. A few minutes later, someone leaned against the wall to listen to him, but the man looked at his watch and started to walk again. Clearly he was late for work. The one who paid the most attention was a 3 year old boy. His mother tagged him along, hurried but the kid stopped to look at the violinist. Finally the mother pushed hard and the child continued to walk tur...