Hello pros!
Im pretty new at Ruby and doing some toturials!
But what i don't understand is how i get the Puts on the same line in
the following code; I know i need to use .chop!? but were in the code?
Ty!
class Hund
def namn (aName)
@myname = aName
end
def skrivnamn
return@myname
end
def color (acolor)
@mycolor = acolor
end
def skrivcolor
return@mycolor
end
def talk
return("den låter följande Woof".center(10))
end
mydog=Hund.new
mydog.namn("Patric Åberg".center(12))
mydog.color("Min hund är röd".center(10))
puts (mydog.skrivnamn)
puts (mydog.skrivcolor)
puts(mydog.talk)
yourdog=Hund.new
yourdog.namn("Karl Svart".center(10))
yourdog.color("Min hund är svart".center(10))
puts (yourdog.skrivnamn)
puts (yourdog.skrivcolor)
puts (yourdog.talk)
end
on 2013-02-26 19:55
on 2013-02-26 20:29
Ryan Davis wrote in post #1099190:
> Either puts "#{a}#{b}#{c}" or print a; print b; puts c
How do you mean, started Ruby today.. (:
on 2013-02-26 20:58
Complete some of the many online tutorials before asking on forums.
"#{ variable }" <- This is called "interpolation". Look it up.
on 2013-02-26 23:12
On Tue, Feb 26, 2013 at 8:13 PM, Ryan Davis <ryand-ruby@zenspider.com>
wrote:
> Either puts "#{a}#{b}#{c}" or print a; print b; puts c
In this case it'd rather be
puts a, b, c
Cheers
robert
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.