Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Platform#deconstruct_keys
deconstruct_keys(keys)
lib/rubygems/platform.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/platform.rb, line 165
def deconstruct_keys(keys)
{ cpu: @cpu, os: @os, version: @version }
end
Deconstructs the platform into a hash for pattern matching. Returns a hash with keys :cpu, :os, and :version.
Example
Gem::Platform.new("x86_64-darwin-20").deconstruct_keys(nil) #=> { cpu: "x86_64", os: "darwin", version: "20" }
This enables hash pattern matching:
Example
case Gem::Platform.new("x86_64-linux") in cpu: "x86_64", os: "linux" # Matches Linux on x86_64 end