Ruby/String/eq

Материал из Wiki.crossplatform.ru

Версия от 17:10, 26 мая 2010; (Обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

eql? and == are slightly different

# == returns true if two objects are Strings, false otherwise.
# eql? returns true if two strings are equal in length and content, false otherwise.
# Here eql? returns false:
hay = "aaa"
aaa = "aaa"
puts (hay.eql? aaa)