{"id":538,"date":"2015-06-18T16:55:18","date_gmt":"2015-06-18T20:55:18","guid":{"rendered":"http:\/\/codefork.com\/blog\/?p=538"},"modified":"2015-06-18T16:56:45","modified_gmt":"2015-06-18T20:56:45","slug":"variable-assignment-quirks-in-ruby","status":"publish","type":"post","link":"https:\/\/codefork.com\/blog\/index.php\/2015\/06\/18\/variable-assignment-quirks-in-ruby\/","title":{"rendered":"Variable assignment quirks in Ruby"},"content":{"rendered":"<pre># irb\r\nirb(main):001:0&gt; puts x\r\nNameError: undefined local variable or method 'x' for main:Object\r\n\tfrom (irb):1\r\n\tfrom \/usr\/bin\/irb:11:in '&lt;main&gt;'\r\n<\/pre>\n<p>Okay. I expected that.<\/p>\n<pre>irb(main):002:0&gt; x = x + 1\r\nNoMethodError: undefined method '+' for nil:NilClass\r\n\tfrom (irb):2\r\n\tfrom \/usr\/bin\/irb:11:in '&lt;main&gt;'\r\n<\/pre>\n<p>Whoa. Did NOT expect that! Wait, so does that mean&#8230;?<\/p>\n<pre>irb(main):003:0&gt; z = z\r\n=> nil\r\n<\/pre>\n<p>Hmm. Okay. Well, time to call it a day.<\/p>\n","protected":false},"excerpt":{"rendered":"<p># irb irb(main):001:0&gt; puts x NameError: undefined local variable or method &#8216;x&#8217; for main:Object from (irb):1 from \/usr\/bin\/irb:11:in &#8216;&lt;main&gt;&#8217; Okay. I expected that. irb(main):002:0&gt; x = x + 1 NoMethodError: undefined method &#8216;+&#8217; for nil:NilClass from (irb):2 from \/usr\/bin\/irb:11:in &#8216;&lt;main&gt;&#8217; Whoa. Did NOT expect that! Wait, so does that mean&#8230;? irb(main):003:0&gt; z = z => &hellip; <a href=\"https:\/\/codefork.com\/blog\/index.php\/2015\/06\/18\/variable-assignment-quirks-in-ruby\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Variable assignment quirks in Ruby&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-538","post","type-post","status-publish","format-standard","hentry","category-ruby"],"_links":{"self":[{"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=538"}],"version-history":[{"count":9,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":547,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions\/547"}],"wp:attachment":[{"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codefork.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}