Questions tagged [learn-ruby-the-hard-way]

Learn Ruby the Hard Way is a free online book on the Ruby language for beginner programmers. It's an adaptation of Zed Shaw's Learn Python the Hard Way translated into Ruby by Rob Sobers.

Learn Ruby the Hard Way is a free online book on the Ruby language for beginner programmers. It's an adaptation of Zed Shaw's Learn Python the Hard Way translated into Ruby by Rob Sobers. It can be found here.

42 questions
0
votes
1 answer

How to call arrays from classes/objects in Ruby (learn ruby the hard way exercise 42)

I am quite new to both Stack Overflow and Ruby so I apologize in advance if I have not formatted something correctly but I would love some assistance on calling or displaying the value of arrays from a parent class through an object. The following…
0
votes
1 answer

Stuck on Learn Ruby The Hard Way #46 rake aborted

I made the project skeleton as described in Learn Ruby The Hard Way #43 and created the structure stated. The problem occurs when I run rake test and the prompt spouts out the following: /home/username/.rbenv/versions/2.2.2/bin/ruby -I"lib:tests" …
JoshyJosh
  • 11
  • 4
0
votes
1 answer

Learn Ruby the hard way Ex 41. - what's with the multi-line string?

Ex41 in Learn Ruby the Hard Way is giving me difficulties. (Namely the "A Reading Test" part.) http://learnrubythehardway.org/book/ex41.html I found qestions about that one here and around the web, but those were regarding other parts of the…
metrazol
  • 119
  • 1
  • 2
  • 11
0
votes
1 answer

Undefined method 'close' for main:Object (NoMethodError) in Ruby

filename = ARGV.first txt = open filename puts "Here's your file #{filename}:" print txt.read puts "Type the filename again: " file_again = $stdin.gets.chomp txt_again = open file_again print txt_again.read close(txt) close(txt_again) The…
Prashanth Chandra
  • 2,672
  • 3
  • 24
  • 42
0
votes
1 answer

Learn Ruby The Hard Way #43

Can someone please explain me what is happening here? I know that this code is simple, but it is hard for me, I am ultimate beginner. I am stucked for many hours here, I cant figure it out.. When I run code, CentralCorridor class is run where we…
Alek
  • 1,461
  • 2
  • 13
  • 14
0
votes
1 answer

Learn Ruby the Hard Way ex39: return -1, key, default

so I'm doing the Learn Ruby the Hard Way exercises and got stuck on one line. Tried googling and even looking for answers in the Python lessons. But Couldnt find an answer. My question is: Why does Dict.get_slot have this line(what is it for?):…
abarro
  • 25
  • 7
0
votes
1 answer

Ruby the hard way example 39

I've tried my best understand how each line of the code works, but it seems I'm just getting more lost as I go. I know http://ruby.learncodethehardway.org/book/ex39.html explains the functions but I'm getting lost on the actual code. An example…
user3799793
  • 131
  • 3
  • 11
0
votes
1 answer

syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('

I 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 = '> ' puts "Hi…
user3408293
  • 1,377
  • 6
  • 18
  • 26
0
votes
2 answers

Ruby(HardWay(ex9)) << uninitialized constant PARAGRAPH

I'm doing Ruby the Hard Way (ex9) -> http://ruby.learncodethehardway.org/book/ex9.html Why can it not find the constant PARAGRAPH? ERROR =>: $ ruby ex9.rb ex9.rb:9: uninitialized constant PARAGRAPH (NameError) CODE (my input): # Here's some new…
Jay Bobo
  • 31
  • 9
0
votes
1 answer

Assigning return value to variable in Ruby in Learn Ruby the Hard Way, exercise 21

In Zed Shaw's Learn Ruby the Hard Way, exercise 21: def add(a, b) puts "ADDING #{a} + #{b}" a + b end age = add(30, 5) puts "Age: #{age}" This prints Age: 35. I tried doing this with the previous exercise (ex20): def print_all(f) puts…
0
votes
1 answer

Writing to file with Ruby in Compilr

I'm banging through Zed A. Shaw's learn code the hard way (Ruby) on compilr and am stuck on exercise 16. filename = ARGV.first target = File.open(filename, 'w') target.truncate(target.size) target.close() In the console, I type run sample.txt This…
OctaviaLo
  • 1,268
  • 2
  • 21
  • 46
-1
votes
1 answer

returning values from a class and getting inexplicable results

I'm trying to make a small game where you go from room to room but when I try to return the value for the next room instead of being the string I intended I get something that looks like this: # instead of …
kugyousha
  • 2,472
  • 3
  • 21
  • 22
1 2
3