038. ruby syntax %{} - cwy007/tips-and-skills GitHub Wiki

1. 解释

one of the above answers actually answer the question.

This is percent sign notation. The percent sign indicates that the next character is a literal delimiter, and you can use any (non alphanumeric) one you want. For example:

%{stuff}
%[stuff]
%?stuff?

etc. This allows you to put double quotes, single quotes etc into the string without escaping:

%{foo='bar with embedded "baz"'}

returns the literal string: foo='bar with embedded "baz"'

The percent sign can be followed by a letter modifier to determine how the string is interpolated.

2. 参考链接

https://stackoverflow.com/questions/5303709/what-does-do-in-ruby