You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often need to add an extension (be it .tmp or .bak for example).
Writing path.sub_ext("#{path.extname}.tmp") is weird. Likewise for path.sub(/\z/, '.tmp'). And unfortunately + and / have exactly the same semantics, so I can't use that either.
Yes, of course, but it feels unnatural, and more importantly it breaks the chain of calls (including /) by being "prefix" instead of suffix. It makes the result harder to read.
Activity
nobu commentedon Dec 9, 2025
You can do
Pathname("#{path}.tmp").akimd commentedon Dec 9, 2025
Hi,
Yes, of course, but it feels unnatural, and more importantly it breaks the chain of calls (including
/) by being "prefix" instead of suffix. It makes the result harder to read.eregon commentedon Dec 9, 2025
FWIW the path gem has add_ext.