Ruby | Array none?() function
Array#none?() : none?() is a Array class method which checks whether the array is empty or not.
Syntax: Array.none?()
Parameter: Array
Return: true – if array has no elements otherwise return false
Example #1 :
a = [ 18 , 22 , 33 , nil , 5 , 6 ]
b = [ 1 , 4 , 1 , 1 , 88 , 9 ]
c = []
puts "none?() method form : #{a.none?()}\n\n"
puts "none?() method form : #{b.none?()}\n\n"
puts "none?() method form : #{c.none?()}\n\n"
|
Output :
none?() method form : false
none?() method form : false
none?() method form : true
Example #2 :
a = [ "abc" , "nil" , "dog" ]
c = [ nil ]
b = [ "cow" , nil , "dog" ]
puts "none?() method form : #{a.none?()}\n\n"
puts "none?() method form : #{b.none?()}\n\n"
puts "none?() method form : #{c.none?()}\n\n"
|
Output :
none?() method form : false
none?() method form : false
none?() method form : true
Last Updated :
06 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...