开发者

how to open a file in ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 5 years ago.

开发者_如何学JAVA Improve this question
path1="c:/amit_150000.txt"
v=1
fs=File.open("$path"+"#{v}",'w')

Now I have to open that file but I am not able to. Please tell me the problem.


fs = File.open("#{path1}#{v}",'w') 


You can open a .rb file in command prompt.

Here are the steps:

  1. Open the command prompt (search for 'command prompt' or 'cmd.exe.') you should see this:

    C:\Users\username>
  2. For example I am keeping this file in Desktop and in a folder named Ruby, type in the path to the folder like this:

    cd Desktop\Ruby

    You should see this:

    C:\Users\username\Desktop\Ruby>
  3. Enter the name of the folder, then the file name:

    Ruby *example.rb*
  4. If else fails, check your code for errors. The command prompt will give you a hint for example:

    example.rb:5: syntax error, unexpected keyword_end, expecting end-of-input

    This means that your error has something to do with the code, end, and is on line 5.

Good luck opening a .rb file!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜