Skip to content

Instantly share code, notes, and snippets.

@makaroni4
Last active August 29, 2015 14:01
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 makaroni4/8ad3131672fce6443066 to your computer and use it in GitHub Desktop.
Save makaroni4/8ad3131672fce6443066 to your computer and use it in GitHub Desktop.
String interpolation in Ruby
require 'ripper'
require 'pp'
sexp = Ripper.sexp '"Hello #{ friend } vs Hello #{friend}"'
pp sexp
# [:program,
# [[:string_literal,
# [:string_content,
# [:@tstring_content, "Hello ", [1, 1]],
# [:string_embexpr, [[:vcall, [:@ident, "friend", [1, 10]]]]],
# [:@tstring_content, " vs Hello ", [1, 18]],
# [:string_embexpr, [[:vcall, [:@ident, "friend", [1, 30]]]]]]]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment