Skip to content

Commit

Permalink
concise
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Jan 12, 2024
1 parent c20cc8f commit c678491
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Library/Homebrew/extend/object/duplicable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class Object
# False for method objects;
# true otherwise.
sig { returns(T::Boolean) }
def duplicable?
true
end
def duplicable? = true
end

class Method
Expand All @@ -36,9 +34,7 @@ class Method
# method(:puts).duplicable? # => false
# method(:puts).dup # => TypeError: allocator undefined for Method
sig { returns(FalseClass) }
def duplicable?
false
end
def duplicable? = false
end

class UnboundMethod
Expand All @@ -47,9 +43,7 @@ class UnboundMethod
# method(:puts).unbind.duplicable? # => false
# method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
sig { returns(FalseClass) }
def duplicable?
false
end
def duplicable? = false
end

require "singleton"
Expand All @@ -59,7 +53,5 @@ module Singleton
#
# Class.new.include(Singleton).instance.dup # TypeError (can't dup instance of singleton
sig { returns(FalseClass) }
def duplicable?
false
end
def duplicable? = false
end

0 comments on commit c678491

Please sign in to comment.