Array#none?() : none?() es un método de clase Array que verifica si la array está vacía o no.
Sintaxis: Array.none?()
Parámetro: Array
Devuelve: verdadero: si la array no tiene elementos, de lo contrario, devuelve falso
Ejemplo 1 :
# Ruby code for none?() method # declaring array a = [18, 22, 33, nil, 5, 6] # declaring array b = [1, 4, 1, 1, 88, 9] # declaring array c = [] # none? method example puts "none?() method form : #{a.none?()}\n\n" puts "none?() method form : #{b.none?()}\n\n" puts "none?() method form : #{c.none?()}\n\n"
Producción :
none?() method form : false none?() method form : false none?() method form : true
Ejemplo #2:
# Ruby code for none?() method # declaring array a = ["abc", "nil", "dog"] # declaring array c = [nil] # declaring array b = ["cow", nil, "dog"] # none? method example puts "none?() method form : #{a.none?()}\n\n" puts "none?() method form : #{b.none?()}\n\n" puts "none?() method form : #{c.none?()}\n\n"
Producción :
none?() method form : false none?() method form : false none?() method form : true
Publicación traducida automáticamente
Artículo escrito por mayank5326 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA