how to open a file in ruby [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
开发者_如何学JAVA Improve this questionpath1="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:
Open the command prompt (search for 'command prompt' or 'cmd.exe.') you should see this:
C:\Users\username>
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>
Enter the name of the folder, then the file name:
Ruby *example.rb*
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!
精彩评论