Created
March 30, 2022 20:05
-
-
Save molawson/c8836bc18d38774fc0ed47db07e734d9 to your computer and use it in GitHub Desktop.
This file contains 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 DefinitelyNotHash | |
def initialize(val) | |
@val = val | |
end | |
end | |
class HashIsh | |
def initialize(val) | |
@val = val | |
end | |
def to_hash | |
{ value: @val } | |
end | |
end | |
class NotQuiteHash | |
def initialize(val) | |
@val = val | |
end | |
def to_h | |
{ value: @val } | |
end | |
end | |
def test(*args, **kwargs) | |
puts "ARGS: #{args.inspect}" | |
puts "KWARGS: #{kwargs.inspect}" | |
end | |
# pry | |
[1] pry(main)> require_relative 'test' | |
=> true | |
[2] pry(main)> test NotHash.new("asdf") | |
ARGS: [#<NotHash:0x0000000153c4e3f8 @val="asdf">] | |
KWARGS: {} | |
=> nil | |
[3] pry(main)> test NotQuiteHash.new("asdf") | |
ARGS: [#<NotQuiteHash:0x0000000153c24620 @val="asdf">] | |
KWARGS: {} | |
=> nil | |
[4] pry(main)> test HashIsh.new("asdf") | |
ARGS: [] | |
KWARGS: {:value=>"asdf"} | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment