Related Articles

Related Articles

Ruby | Array class frozen?() operation
  • Last Updated : 08 Jan, 2020

Array#frozen?() : frozen?() is a Array class method which checks whether the array is frozen (or temporarily frozen while being sorted)

Syntax: Array.frozen?()

Parameter: Array to check

Return: true – if array is frozen; otherwise false

Code #1 : Example for frozen?() method



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for frozen?() method
  
# declaring array
a = [18, 22, 33, nil, 5, 6]
  
# declaring array
b = [1, 4, 1, 1, 88, 9]
  
# declaring array
c = [18, 22, nil, nil, 50, 6]
  
# frozen?
puts "frozen? : #{a.frozen?()}\n\n"
  
# frozen?
puts "frozen? : #{b.frozen?()}\n\n"
  
# frozen?
puts "frozen? : #{c.frozen?()}\n\n"

chevron_right


Output :

frozen? : false

frozen? : false

frozen? : false

Code #2 : Example for frozen?() method

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for frozen?() method
  
# declaring array
a = ["abc", "nil", "dog"]
  
# declaring array
b = ["cow", nil, "dog"]
  
# declaring array
c = ["cat", nil, nil]
  
# frozen?
puts "frozen? : #{a.frozen?()}\n\n"
  
# frozen?
puts "frozen? : #{b.frozen?()}\n\n"
  
# frozen?
puts "frozen? : #{c.frozen?()}\n\n"

chevron_right


Output :

frozen? : false

frozen? : false

frozen? : false



My Personal Notes arrow_drop_up
Recommended Articles
Page :