Code, Strings, and Keys

    • About Thomas Powell
    • Account
    • It’s been [0] days since [program] last updated
    • Login
    • Password Reset
    • Pianist / Accompanist / Music Director Resume
    • Reading List 2025
    • Register
    • Running Gear – Shoes, Treadmill, and Bandages
    • Site Map
Illustration of a bird flying.
  • Extending Immediate Types and Source Locations in Ruby

    Overridding singleton classes of instances In Ruby, most types allow you to open up their singleton classes to override instance methods: Immediate values Some objects are implemented as immediate values in Ruby, and cannot be implemented have singleton methods defined on them directly: Fixnum, true, nil, and false are implemented as immediate values. With immediate values, variables hold the…

    December 2, 2024
  • Conditional gems in ruby without breaking Gemfile.lock

    Do you want ruby/bundler to skip a gem install on a certain platform, but any other platform needs that gem? The obvious answer would be the following, which would result in also clobbering your Gemfile.lock if bundling on macOS: gem “openssl”, “= 3.2.0” if RUBY_PLATFORM !~ /darwin/ But bundler has its own method, install_if , to accomplish such a…

    July 31, 2024
  • Handling keyword arguments in method_missing in Ruby

    If you implement a method_missing method to receive methods that receive keyword arguments and you only receive and forward (to send) the method name, *args, and &block, you will receive ArgumentError: wrong number of arguments (given 3, expected 2) when the arguments are forwarded. This is because the keyword arguments will revert to the backward-compatible…

    April 4, 2024
←Previous Page
1 2 3 4 5 6 … 310
Next Page→

Code, Strings, and Keys

Proudly powered by WordPress