I came from the Java world, so I was shocked to find that arrays ( http://ruby-doc.org/core/classes/Array.html ) do not have a method contains(object)that returns bool.
contains(object)
bool
What is a good way - ruby way - to do this?
array.include? (obj) → true or false
Returns true if the given object is present in self (that is, if some object == anObject), otherwise false.
a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false
This is from the Array class documentation :
[1,2,3].include? 2 => true
ruby-1.9.2-p0 > [1,2,3].include? 3 => true ruby-1.9.2-p0 > [1,2,3].include? 33 => false
:
Array.index("ITEM")
!= de nil, .
.
Source: https://habr.com/ru/post/1773021/More articles:Obfuscation in .NET vs. Delphi - .netlogin to enter the system software - liferayHow to remember selected flags between each paging press - checkboxInternet Explorer does not monitor relative domain forwarding URLs - redirectchange the path variable of the parent shell in the shell script - shellSWFLoader/ApplicationDomain: проблема масштабирования при использовании нового домена в загруженном приложении - flexC # how to make Windows 7 aero winform (colored glass)? - c #SQL Server Copying records from one column to another - sqlКак записать живой аудио вход в файл с микрофона с помощью openAL? (Код С++ внутри) - c++Windows Forms glass effect, make ImageBox transparent - c #All Articles