Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个可以是“+”、“-”、“*”或“/”的字符串和两个数字。我需要将字符串表示的操作应用于数字。我试过了:
op = '+' (&op.to_sym).call 1, 2
但它不会解析它。请帮忙。
Ruby 不是波兰符号语言。
1.send(op, 2)