Ruby Keywords | Alchemists

Ask questions Research chat →

https://alchemists.io/articles/ruby_keywords · scraped

ruby

Attachments

Scraped Content

— 70 words · 2026-02-14 03:15:18 UTC ·

Excerpt

def demo(**attributes) case attributes in name:, **nil then puts "Name: #{name}." in name:, label: String => label then puts "Name: #{name}, Label: #{label}." in {} then puts "No attributes found." else puts "Unable to match: #{attributes}." end end demo name: "demo" # "Name: demo." demo name: "demo", label: "Demo" # "Name: demo, Label: Demo." demo # "No attributes found." demo x: 1, y: 2 # "Unable to match: {:x=>1, :y=>2}."
def demo(**attributes) case attributes in name:, **nil then puts "Name: #{name}." in name:, label: String => label then puts "Name: #{name}, Label: #{label}." in {} then puts "No attributes found." else puts "Unable to match: #{attributes}." end end demo name: "demo" # "Name: demo." demo name: "demo", label: "Demo" # "Name: demo, Label: Demo." demo # "No attributes found." demo x: 1, y: 2 # "Unable to match: {:x=>1, :y=>2}."

Visibility

Visible to everyone

Reading Status

Related Bookmarks

My Note


Saved!

Annotations

Export as Markdown
+ Annotate selection

Add Annotation