3

I am new to Ruby and am trying to learn from a book. However, I have one problem – it says I should save a file so that it ends with .rb but my Mac only lets me use .rtf so that's what I used. But the next thing I needed to do was open it in Terminal and the command cd /Users/username/ruby didn't work for me. I'm guessing the reason for this is because I didn't use .rb it didn't work.

So my question is: What should I use for writing Ruby in the end of that command, or for saving with the .rb extension?

Synoli
  • 1,271
  • 8
  • 14
josh
  • 31

3 Answers3

5

You could only save as .rtf because the file was rich text. To make it plain text, simply press ⇧ shift-⌘ command-T or go Format > Make Plain Text, then you can save as .rb.

Try not to use TextEdit: there is no syntax highlighting and code completion, not to mention that you have to manually turn off those wrong quotation marks.

paper1111
  • 625
2

What you do is get yourself a proper code editor or IDE. Using TextEdit to write code is a very bad idea. Personally I'd recommend Sublime Text 3 because it has good text highlighting for many different languages, is free (well technically isn't, but for learning like you're doing, not buying a license should be ok), and is pretty lightweight but you should do some research and reach your own conclusions about which code editor or IDE is right for you.

NoahL
  • 3,517
1

Could always use good ole vim YOURFILENAMEHERE.rb within Terminal.

When you want to type, enter insertion mode by pressing i; if you want to exit insertion mode, press ESC. Then to save your file just press :wqEnter (save and then quit).

Of course you miss out on all of the IDE features but it's a great text editor that is built in.

Synoli
  • 1,271
  • 8
  • 14
unjankify
  • 181