Thursday, April 8, 2010

Difference between "and" and "&&"

klasses = ['last'] && txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain "".

klasses = ['last'] and txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain ['last'] which was what I intended. But the first statement wasn't returning that.

A good explanation is here http://stackoverflow.com/questions/1426826/difference-between-and-and-in-ruby

35 comments:

Anonymous said...

It's great!!..........................................

Anonymous said...

It's great!!..................................................

Anonymous said...

hello~welcome my world~<. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Anonymous said...

文章很棒~感謝!!..................................................

Anonymous said...

Of two evils choose the least.......................................................

Anonymous said...

累死了…來去看看文章轉換心情~..................................................

火吟 said...

nice to meet you~.................................................................

Anonymous said...

Lets cross the bridge when we come to it..................................................

紫倫妍勳 said...

加油!充實內函最重要!Beauty is but skin- deep...................................................

Anonymous said...

聰明的人喜歡猜心 雖然每次都猜對了卻失去了自己的心..................................................

明英 said...

婚姻對男人來說是賭他的自由,對女人而言卻是賭她的幸福。..................................................................

Anonymous said...

Keep in contact. Good Luck..................................................

Anonymous said...

一個人的價值,應該看他貢獻了什麼,而不是他取得了什麼.................................................................                           

Anonymous said...

Quality is better than quantity.................................................................

Anonymous said...

向著星球長驅直進的人,反比踟躕在峽路上的人,更容易達到目的。............................................................

Anonymous said...

當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。............................................................

Anonymous said...

朋友是一面鏡子............................................................

Anonymous said...

單純喜歡你的部落格 留個言跟您問聲好~~............................................................

Anonymous said...

文章雖然普通,但意義卻很大~~^^~~ ..................................................................

Anonymous said...

河水永遠是相同的,可是每一剎那又都是新的。

Anonymous said...

卡爾.桑得柏:「除非先有夢,否則一切皆不成。」共勉!..................................................................

Anonymous said...

要持續更新下去喲!!祝你心情愉快..................................................................

Anonymous said...

這麼用心的經營你的文章, 當然值得我們留連拜訪的!..................................................................

Anonymous said...

缺少智慧,就是缺少一切..................................................

Anonymous said...

時間就是塑造生命的材料。

Anonymous said...

你不能改變容貌~~但你可以展現笑容.................................................................

Anonymous said...

良言一句三冬暖,惡語傷人六月寒。......................................................................

Anonymous said...

不錯的資訊~我會好好記下來!............................................................

文王廷 said...

愛,拆開來是心和受兩個字。用心去接受對方的一切,用心去愛對方的所有。......................................................................

Anonymous said...

人不能像動物一樣活著,而應該追求知識和美德............................................................

Anonymous said...

讓好心情回味發酵;壞心情留在文字裡隨時間消逝吧!............................................................

Anonymous said...

愛情是盲目的,但婚姻恢復了它的視力。......................................................................

Anonymous said...

聰明人之所以不會成功,是因為他們缺乏了堅忍的毅力。.................................................

Anonymous said...

人生中最好的禮物就是屬於自己的一部份............................. ....................................

張王雅竹欣虹 said...

一個人的際遇在第一次總是最深刻的,有時候甚至會讓人的心變成永遠的絕緣。......................................................................