Skip to content

Instantly share code, notes, and snippets.

@DNNX

DNNX/answer.rb Secret

Created April 16, 2017 18:07
Show Gist options
  • Select an option

  • Save DNNX/d45043a4cea754b3e0bbfa0a47d5a8a5 to your computer and use it in GitHub Desktop.

Select an option

Save DNNX/d45043a4cea754b3e0bbfa0a47d5a8a5 to your computer and use it in GitHub Desktop.
excellent-7-fix
MyClass = Class.new { def ===(_); rand < 0.5; end }.new
# Who said `MyClass` should be a class? Principle of least surprise, remember!
@pirj

pirj commented May 18, 2017

Copy link
Copy Markdown

I thought of class MyClass; def self.===(_); @x=!@x; end; end

@DNNX

DNNX commented Jun 28, 2017

Copy link
Copy Markdown
Author

yep, this is even better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment