Programming With Ruby Episode 6, Strings

preview_player
Показать описание
In this episode you learn about using strings in Ruby. More specifically: String literals, string expressions, useful string methods, regular expressions, and getting user input

Рекомендации по теме
Комментарии
Автор

You sir, have just earned yourself a subscriber.

CaptainGibbons
Автор

its above the Enter key

Glad you like the videos!

manwithcode
Автор

@parks709 What's surrounded by the "/"s is called a regular expression. It's a way of processing text. "." means, select any character. "\w" is for whitespace. Regular expressions are a huge topic, so just do a Google search to find out more.

manwithcode
Автор

hmm... from what I can tell, it might the button to the right of left-shift on your keyboard. Try pressing that key with shift and/or alt and see if the right letter pops out.

As for books, I thought Beginning Ruby From Novice to Professional was good.

manwithcode
Автор

It's the same as displaying a string except you have to use the "to underscore s" method on the variable.

(Youtube is being a pain, the method I talk about has no spaces, and it is the underscore character, not the word)

manwithcode
Автор

(Woah, i accidentally deleted someone's comment when I meant to hit reply, sorry)
For everyone having trouble finding the pipe character: |, I haven't found a keyboard without it (though all the ones that I come in contact with are usually USA configuration, I haven't checked out any international ones). Keep in mind that it's usually above the enter key, and that it may not look like a complete line, it can have a break in the middle of it. Don't worry, it's still the same key.

manwithcode
Автор

@whitedragon812 If the code looks the way you posted it in your comments, the problem is a syntax error. There aren't supposed to be square brackets around the x variable, it's supposed to be the pipe character (usually found above the enter key).
It should look like this: |x|
Not this: [x]

manwithcode
Автор

I don't really understand the scan expression. Could you explain more on what (/../) or (/\w\w/) do?

parks
Автор

Not on mine :P probably different on an EU keyboard. I'll find it in the end, thanks for the response.

Doing an AS level in Computing in September, so will probably learn more then, but if you could recommend one book to me, what would it be?

I'm still basically a beginner, i've done some sketchy C++ work, and worked through your video's, but that's about it.

Thank you :)

slike
Автор

How do I display a number stored in a variable as a string?

packered
Автор

i cant find the symbol on each end of the x on my keyboard!? where abouts is it?

Really nice videos, learning alot

slike
Автор

I cant get the a = gets to work, whenever I write it in the code and run the program, it spits out "Errno::EBADF occorred
Bad file descrptor"

Ashadow
Автор

@cashjamesPremium1 Odd. I've never seen this happen before. Are you on Windows? What version of Ruby are you running?

manwithcode
Автор

@cashjamesPremium1 I haven't been able to reproduce the problem you're encountering, are you sure you've typed the code in correctly?

manwithcode
Автор

I am using latest version of ruby interactive on windows 7. When I type "Hello".each_char do [x], the program is giving me an error that says undefined variable. Is there a way to fix this?

Earl
Автор

@Annuix
try typing in
require 'jcode'

elputube
Автор

Sorry for taking so long to respond...

I'm not sure why each_char isn't being recognized, what version of Ruby are you using?

manwithcode
Автор

I've never seen that error before, and I can't figure out how to replicate it.

Sorry.

manwithcode
Автор

@CaptainGibbons lol what a coincidence I subscribed also. . . and I know you XD

cvorwell
welcome to shbcf.ru