Ruby in 20 mins lesson inconsistent?

red_codec

Villager
Member
Joined
Sep 9, 2014
Messages
38
Reaction score
1
First Language
English
Primarily Uses
Hi guys, I'm learning ruby and trying out the exercise from 

https://www.ruby-lang.org/en/documentation/quickstart/2/

I encountered a problem. 

irb(main):015:0> def h(name)irb(main):016:1> puts "Hello #{name}!"irb(main):017:1> end=> :hDoing this gets me inconsistent results. Sometimes after the third line 'end', i do not get a => :h back, meaning ruby didn't register what i wrote earlier. I checked each time to ensure the first 2 lines I input is the exact same with no character incorrect but I get different results some of the time. 

Anyone knows what's going on? :( ((
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,848
First Language
English
What happens if you type something like

Code:
h('test')
 

red_codec

Villager
Member
Joined
Sep 9, 2014
Messages
38
Reaction score
1
First Language
English
Primarily Uses
What happens if you type something like

h('test')
I get:

irb(main):001:0> h<'test')SyntaxError: (irb):1: syntax error, unexpected ')', expecting end-of-input from D:/Program Files/Ruby22-x64/bin/irb:11:in `<main>'irb(main):002:0>Totally ignoring this lesson and learning from codeacademy instead.
 
Last edited by a moderator:

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
You're likely doing something wrong (see the previous post < isn't ), is it?). You won't get a better answer since you've posted a working irb log. Post a complete one that shows your inconsistent or incorrect results.


Also note that in all RGSS versions def-expressions always return nil. RGSS3 uses Ruby 1.9.2p0 and returning the method name as symbol is a Ruby 2.1 feature.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top