Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created January 31, 2014 22:22
Show Gist options
  • Save nedzadarek/8744476 to your computer and use it in GitHub Desktop.
Save nedzadarek/8744476 to your computer and use it in GitHub Desktop.
Closing and opening brackets - tests
# You should have the same amount of `{` as `}`
# 2
%Q{{hi}}
# => "{hi}"
# 4
%Q{{{{42}}}}
# => "{{{42}}}"
# `{`: 2; `}`:3
# too much of `}`
%Q{{hi}}}
#SyntaxError: unexpected '}', expecting $end
# however you can escape it:
%q{\{hi}
#=> "{hi"
# or closing bracket:
%q{hi\}}
# => "hi}"
# here, I closed it prematuely:
%Q{}hi}
# SyntaxError: unexpected tIDENTIFIER, expecting $end
# %Q{}hi}
# ^
# here, any of closing brackets doesn't close "Q's" opening bracket
%Q{{}hi{}}
# => "{}hi{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment