#ruby
Read more stories on Hashnode
Articles with this tag
You might have seen this solution. Object.send(:remove_const, :ExampleClass) But what if you want to remove namespaced classes in Ruby. You can use...
Class instance variables are variables that have punctual prefix @ and are used inside class definition. class Shape @count = 6 def...
Class variable Class variables are variables prefixed by @@ . class Shape @@no_of_shapes = 6 def instance_method_x puts "No:...
Problem: Convert 'ABCD' to {"A"=>0, "B"=>0, "C"=>0, "D"=>0} Using inject 'ABCD'.chars.inject({}) { |memo, v| memo[v] = 0; memo } Using Hash ...
include: makes instance methods from module as instance methods When you include a module inside class. All the instance method from the module...