views:

1812

answers:

6

I know this is simple, but how do you take a string and convert it to lower case, or upper case in ruby.

+3  A: 

"string".downcase

Heat Miser
I found the answer, but it took me way too long, it is better here...
Heat Miser
Instead of answering the question yourself, you might wait for someone else to post so you can give them points.
Ben Alpert
ruby conversions here: http://www.techotopia.com/index.php/Ruby_String_Conversions
TStamper
+11  A: 
string.downcase

or if you want to modify the string in place:

string.downcase!
Ben Alpert
I only thought about it after I had answered it, but I'll give you the cred for taking the time to answer it anyway. Thanks!
Heat Miser
It's okay. I appreciate the points, though. Thanks!
Ben Alpert
+2  A: 

. downcase

+3  A: 

http://www.ruby-doc.org/core/classes/String.html

Not, trying to be sarcastic, just passing along a very useful tool

I usually just put "Ruby, Class, Datatype" into google and the appropriate rubydoc pops up

very handy

+1  A: 

... and the uppercase is:

"Awesome String".upcase
=> "AWESOME STRING"
mlambie
+4  A: 

You can find out all the methods available on a String by opening irb and running:

"MyString".methods.sort

And for a list of the methods available for strings in particular:

"MyString".own_methods.sort

I use this to find out new and interesting things about objects which I might not otherwise have known existed.

mlambie