If I do the following, for example:
foo = ["bar"]
foo.keep_if {|n| foo.last.obect_id == n.object_id}
Is there another way I can refer to foo inside the block instead of naming it, something like “n.container”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
No, there isn’t. An object can appear in any number of containers (and there is no protocol for containers to tell objects, “Yo, I’mma contain you now”), so it isn’t really practical. Just using the existing variable in your block is the cleanest way to do it.