Why can't I do this?
>> s = String >> s(42) s(42) NoMethodError: undefined method `s' for main:Object from (irb):86 from /home/sam/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Further.
>> String.new 42 String.new 42 TypeError: can't convert Fixnum into String from (irb):90:in `initialize' from (irb):90:in `new' from (irb):90 from /home/sam/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
How does String () convert Fixnum to String if String.new can't? I assume String () calls to_s. But then, what does String.new look for besides the string to copy? Is the new alias for dup?
, s(42) , , String ( ), String ( to_s). s = String, s , String. , s(42), ruby s, .
s(42)
String
to_s
s = String
s
, ruby , .
String(42) String.new(42) , String to_s String.new to_str.
String(42)
String.new(42)
String.new
to_str
"42", s = "42" - , .
s = "42"
Fixnum, , s = some_fixnum.to_s .
s = some_fixnum.to_s
Source: https://habr.com/ru/post/1789897/More articles:Run Python code from PyQt event loop - pythonDelphi7 - How can I find where my project hangs in the compiler? - compiler-constructionexplicit destructor - c ++How to set the correct width for mobile webpage on iphone - iphoneAsyncController OutputCache - asp.net-mvc-3https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1789898/can-you-send-different-view-models-to-a-view&usg=ALkJrhh3cs0K0djDBgus-6CUq0eNnRetQgphp get_meta_tags не запрашивает свойство = теги "og: type" - functionJavascript mongodb update - javascriptJLabel click event - javaShould I use SendDlgItemMessage or is there a wrapper for this in WTL? - windowsAll Articles