Last active
July 31, 2021 15:03
-
-
Save JoshCheek/43b15b9123e337ee6a118cb6ff4c7e7a to your computer and use it in GitHub Desktop.
The flag that `ruby2_keywords` uses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://twitter.com/josh_cheek/status/1421462056994283521 | |
| require 'fiddle' | |
| public def address() = Fiddle.dlwrap(self) | |
| public def pointer() = Fiddle::Pointer.new(address) | |
| public def toggle_keywords!() = (pointer[1] ^= 0b100000) | |
| def m(a:) = a | |
| h = {a: 1} | |
| m *[h] rescue $! # => #<ArgumentError: wrong number of arguments (given 1, expected 0; required keyword: a)> | |
| h.toggle_keywords! | |
| m *[h] rescue $! # => 1 | |
| h.toggle_keywords! | |
| m *[h] rescue $! # => #<ArgumentError: wrong number of arguments (given 1, expected 0; required keyword: a)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment