Skip to content

Instantly share code, notes, and snippets.

@phluid61
Last active February 1, 2018 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phluid61/2932b6ab714a9e01e049cc6dcecb32bb to your computer and use it in GitHub Desktop.
Save phluid61/2932b6ab714a9e01e049cc6dcecb32bb to your computer and use it in GitHub Desktop.
The best way to generate strings in Ruby...
# A Percent character '%'
eval '% %s %% % '
# (wrapped in `eval` to highlight the trailing space, which is critical)
# A Question-mark character '?'
%?%s?%??
# A Hash character '#'
%{#{%##%%##}#}
# BONUS: '??'
%{#{%?#{??}?}#{%?#{??}?}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment