This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def to_s | |
'hash' | |
end | |
end | |
h = {} | |
p h.to_s # => "hash" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Symbol.all_symbols.length # => 3893 | |
Symbol.all_symbols.grep(/Struct/) # => [:Struct] | |
:dummy_symbol | |
Symbol.all_symbols.length # => 3894 | |
Symbol.all_symbols.grep(/dummy_symbol/) # => [:dummy_symbol] | |
dummy_variable = nil | |
Symbol.all_symbols.length # => 3895 | |
Symbol.all_symbols.grep(/dummy_variable/) # => [:dummy_variable] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'pending'.object_id # => 70324176174080 | |
'pending'.object_id # => 70324176168090 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:pending.object_id # => 1277788 | |
:pending.object_id # => 1277788 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A | |
autoload(:B, './b.rb') | |
p constants | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload(:C, './c.rb') | |
module A | |
p autoload? :C | |
end | |
p autoload? :C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A | |
autoload(:B, './b.rb') | |
p autoload?(:B) | |
B | |
p autoload?(:B) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Engine | |
puts 'The Engine module is loading!' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Car | |
autoload(:Engine, './engine.rb') | |
puts "The Engine module isn't yet loaded!" | |
Engine | |
puts "The Engine module has been successfully loaded!" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def my_map | |
return self.dup unless block_given? | |
ary = [] | |
self.each do |elem| | |
ary << yield(elem) | |
end | |
ary |