{"id":7048,"date":"2014-05-17T00:24:53","date_gmt":"2014-05-17T00:24:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/problem-about-learn-ruby-the-hard-way-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:24:53","modified_gmt":"2014-05-17T00:24:53","slug":"problem-about-learn-ruby-the-hard-way-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/problem-about-learn-ruby-the-hard-way-collection-of-common-programming-errors\/","title":{"rendered":"problem about learn-ruby-the-hard-way-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/1299099992\/picture?type=large\" \/><br \/>\nJay Bobo<br \/>\nruby learn-ruby-the-hard-way<br \/>\nI&#8217;m doing Ruby the Hard Way (ex9) -&gt; http:\/\/ruby.learncodethehardway.org\/book\/ex9.html Why can it not find the constant PARAGRAPH?ERROR =&gt;:$ ruby ex9.rb ex9.rb:9: uninitialized constant PARAGRAPH (NameError)CODE (my input): # Here&#8217;s some new strange stuff, remember type it exactly.days = &#8220;Mon Tue Wed Thu Fri Sat Sun&#8221; months = &#8220;Jan\\n\\Feb\\nMar\\nApr\\nMay\\nJun\\nJul\\nAug&#8221;puts = &#8220;Here are the days: &#8220;, days puts = &#8220;Here are the months: &#8220;, monthsputs &lt;&lt;PARAGRAPH Theres something going on here. Wit<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/19b61e94b09e359174fc3c9b27a06959?s=128&amp;d=identicon&amp;r=PG\" \/><br \/>\nSam<br \/>\nruby learn-ruby-the-hard-way<br \/>\nI am basically halfway done with Zed Shaw&#8217;s introduction to Ruby course. However, I am stuck at a roadblock with this exercise where he gives me a piece of code and asks me to fix it. Alot of the errors were grammatical but some of the coding ones I can&#8217;t quite pick up.The errors I get are as follows:ex26.rb:76: syntax error, unexpected &#8216;)&#8217;, expecting &#8216;=&#8217;ex26.rb:99: syntax error, unexpected $end, expecting &#8216;)&#8217;The code:# This function will break up words for def break_words(stuff)words = stuff.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/zL1re.jpg?s=32&amp;g=1\" \/><br \/>\nsawa<br \/>\nruby-on-rails ruby ruby-on-rails-4 learn-ruby-the-hard-way<br \/>\nI am following Learn Ruby The Hard Way chapter 14. I typed it out myself what is on the tutorial. I even tried copying and pasting what is on the tutorial itself. My text file ex.rb has the following:user = ARGV.first prompt = &#8216;&gt; &#8216;puts &#8220;Hi #{user}, I&#8217;m the #{$0} script.&#8221; puts &#8220;I&#8217;d like to ask you a few questions.&#8221; puts &#8220;Do you like me #{user}?&#8221; print prompt likes = STDIN.gets.chomp()puts &#8220;Where do you live #{user}?&#8221; print prompt lives = STDIN.gets.chomp()puts &#8220;What kind of computer do you hav<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/01bbb59a1c3ef9960f25a97afe7e920f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrew Grimm<br \/>\nruby learn-ruby-the-hard-way<br \/>\nI am currently on Lesson 9 in &#8220;Learn Ruby the hard way&#8221;.I have typed the the line number 6 exactly as the way its being instructed but still I am getting error while executing.It says:Syntax error, unexpected tCONSTANT, expecting $endputs &#8221; Here ^ are the days : &#8220;, days<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/42e10e7df6c5f098e09e8d4a1d612cc3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJauny<br \/>\nruby class learn-ruby-the-hard-way<br \/>\nI understand how classes work and how to make them, but the 2nd extra credit of the exercice says to create a two-class version, in 2 different files.I tried different things, but I can&#8217;t figure out how to make it work&#8230;I don&#8217;t know if I&#8217;m not searching at the right places, but I can&#8217;t find any help on that, nor find any solution&#8230;If anyone could help me on that, it would be much appreciated :)here is the exercice : http:\/\/ruby.learncodethehardway.org\/book\/ex42.htmlWhat I have tried so far :ma<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/01bbb59a1c3ef9960f25a97afe7e920f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrew Grimm<br \/>\nruby function loops while-loop learn-ruby-the-hard-way<br \/>\nI&#8217;m on Chapter 33 of Learn Ruby the Hard Way.Extra credit exercise 1 asks:Convert this while loop to a function that you can call, and replace 6in the test (i &lt; 6) with a variable.The code:i = 0 numbers = []while i &lt; 6puts &#8220;At the top i is #{i}&#8221;numbers.push(i)i = i + 1puts &#8220;Numbers now: #{numbers}&#8221;puts &#8220;At the bottom i is #{i}&#8221; endputs &#8220;The numbers: &#8220;for num in numbersputs num endMy attempt:i = 0 numbers = []def loops while i &lt; 6puts &#8220;At the top i is #{i}&#8221;numbers.push(i)i = i + 1puts &#8220;N<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/01bbb59a1c3ef9960f25a97afe7e920f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrew Grimm<br \/>\nruby unit-testing learn-ruby-the-hard-way<br \/>\nI&#8217;m working on this Exercise 49 in Learn Ruby the Hard WayThe exercise asks to write a unit test for each function provided. One of the unit tests I am writing is giving me an error.Here is the code I am testing (word_list is an array of Pair structs)Pair = Struct.new(:token, :word)def peek(word_list)beginword_list.first.tokenrescuenilend enddef match(word_list, expecting)beginword = word_list.shiftif word.token == expectingwordelsenilendrescuenilend enddef skip(word_list, token)while peek(word_<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n<p>I discovery a place to host code\u3001demo\u3001 blog and websites.<br \/>\nSite access is fast but not money<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.m5zn.com\/newuploads\/2014\/01\/30\/jpg\/e7da807964b1fff.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jay Bobo ruby learn-ruby-the-hard-way I&#8217;m doing Ruby the Hard Way (ex9) -&gt; http:\/\/ruby.learncodethehardway.org\/book\/ex9.html Why can it not find the constant PARAGRAPH?ERROR =&gt;:$ ruby ex9.rb ex9.rb:9: uninitialized constant PARAGRAPH (NameError)CODE (my input): # Here&#8217;s some new strange stuff, remember type it exactly.days = &#8220;Mon Tue Wed Thu Fri Sat Sun&#8221; months = &#8220;Jan\\n\\Feb\\nMar\\nApr\\nMay\\nJun\\nJul\\nAug&#8221;puts = &#8220;Here are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7048","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7048"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7048\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}