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.
文字列内でどのように減算を行いますか? 90% ではなく 0 になります。
#!/bin/ruby puts " some text #{100%10} some text "
%のエイリアスですmodulo。
%
modulo
10 / 3 #=> 3 10 % 3 #=> 1
私はあなたが書きたいと思います:
puts " some text #{100 - 10}% some text "
この場合、答えは 0 です。なぜなら100%10、割り算の余りが 0 だからです。100 は 10 で割り切れます-。
100%10
-