From: "Luca (Email)" Date: 2011-12-29T15:44:31+09:00 Subject: I: Why are there so many similar/identical methods in core classes -----Messaggio originale----- Da: Kassym Dorsel [mailto:k.dorsel@gmail.com] Inviato: venerd́ 2 dicembre 2011 04:16 A: ruby-talk ML Oggetto: Why are there so many similar/identical methods in core classes Let's look at the Array class and start with method aliases. There are two aliases : .to_s <=> inspect , .size <=> .length , index <=> find_index. I understand the need for the first one, since sometimes the two don't return the same thing depending on the class. But why have size/length do the exact same thing..? This is one pretty intuitive so it's not that bad.h Then we have methods that are defined together, but with different names : collect <=> map , [] <=> slice <=> at. Next we have methods that seem to be doing the same thing, but are implemented differently : keep_if <=> select! , reject! <=> delete_if , delete_at <=> slice! <=> shift Next are the nearly identical methods. They are the same except one does a little : count <=> length/size Useless methods? : replace. Why do you need an explicit method for this. Can't you just use the assignment operator ? These are just the ones I remember/found. I'm sure there are many more examples in this class and others. Doesn't having multiple names for the same thing make it confusing when collaborating ? Is there any reason for this ? What is your take on the matter ? -- Posted via http://www.ruby-forum.com/. -- Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Riccione Hotel 3 stelle in centro: Pacchetto Capodanno mezza pensione, animazione bimbi, zona relax, parcheggio. Scopri l'offerta solo per oggi... Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid982&d)-12