Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:03:01+00:00 2026-05-31T05:03:01+00:00

This article mentions 4 ways to invoke procs in ruby 1.9, and === is

  • 0

This article mentions 4 ways to invoke procs in ruby 1.9, and === is one of them. I don’t understand why this would be done this way at all. Does it have any relationship to the normal meaning of === (asking if the two objects are the same object)?

irb(main):010:0> f =-> n {[:hello, n]}
=> #
irb(main):011:0> f.call(:hello)
=> [:hello, :hello]
irb(main):012:0> f === :hello
=> [:hello, :hello]
irb(main):013:0> Object.new === Object.new
=> false
irb(main):014:0> f === f
=> [:hello, #]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:03:02+00:00Added an answer on May 31, 2026 at 5:03 am

    This is what the docs have to say:

    It is to allow a proc object to be a target of when clause in the
    case statement.

    This is a, perhaps contrived, example:

    even = proc { |x| x % 2 == 0 }
    n = 3
    case n
    when even
      puts "even!"
    else
      puts "odd!"
    end
    

    It works because the case/when is basically executed like this:

    if even === n
      puts "even!"
    else
      puts "odd!"
    end
    

    The case/when checks which branch to execute by calling === on the arguments to when clauses, picking the first that returns a truthy value.

    Despite its similarity to the equality operator (==) it not a stronger or weaker form of it. I try to think of the === operator as the “belongs to” operator. Class defines it so that you can check if an object belongs to the class (i.e. is an instance of the class or a subclass of the class), Range defines it as to check if the argument belongs to the range (i.e. is included in the range), and so on. This doesn’t really make the Proc case make more sense, but think of it as a tool for making your own belongs to operators, like my example above; I defined an object that can determine if something belongs to the set of even numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just reading this article and it mentions that some organization had an
This article describes a way, in C#, to allow the addition of arbitrary value
This article about php form security: http://nedbatchelder.com/text/stopbots.html ... mentions a spinner as: The spinner
This article mentions the availability of a dropdown of default event handlers in Visual
I've recently come across this rant . I don't quite understand a few of
In this article on thserverside.com: http://www.theserverside.com/news/thread.tss?thread_id=42651 It mentions :JBoss has released Hibernate 3.2, their
The wikipedia article on Singletons mentions a few thread safe ways to implement the
I came across this article , which mentions wrapping everything in a single element
This article gives a good overview on why structured exception handling is bad. Is
This article here suggests to use -XX:+UseParNewGC To enable a parallel young generation GC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.