Last active
February 14, 2018 04:14
-
-
Save IotaSpencer/a1f52908fc5d1ba570d87098e6ed11c7 to your computer and use it in GitHub Desktop.
Ruby assignment operators on strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[6] pry(main)> f *= 9 | |
=> "rubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygems" | |
[7] pry(main)> f /= 9 | |
NoMethodError: undefined method `/' for #<String:0x0000000148ad40> | |
from (pry):7:in `__pry__' | |
[8] pry(main)> f -= 9 | |
NoMethodError: undefined method `-' for #<String:0x0000000148ad40> | |
Did you mean? -@ | |
from (pry):8:in `__pry__' | |
[9] pry(main)> f += 9 | |
TypeError: no implicit conversion of Fixnum into String | |
from (pry):9:in `+' | |
[10] pry(main)> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ken@kenny:~$ pry | |
[1] pry(main)> f = 'ruby' | |
=> "ruby" | |
[2] pry(main)> f *= 'gems' | |
TypeError: no implicit conversion of String into Integer | |
from (pry):2:in `*' | |
[3] pry(main)> f /= 'gems' | |
NoMethodError: undefined method `/' for "ruby":String | |
from (pry):3:in `__pry__' | |
[4] pry(main)> f += 'gems' | |
=> "rubygems" | |
[5] pry(main)> f -= 'gems' | |
NoMethodError: undefined method `-' for "rubygems":String | |
Did you mean? -@ | |
from (pry):5:in `__pry__' | |
[6] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment