Want to create a file with variable name

hi i want to create a file name, with that variable name…

for example…

a=10

f=File.open(‘a.txt’,‘a’)
created file name is a.txt
but
i want the file as 10.txt

can any one help??

Try:

f = File.open("#{a}.txt",‘a’)

Regards, John.

John Slobbe wrote:

Try:

f = File.open("#{a}.txt",‘a’)

Regards, John.

Thank You so much john…
its working.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs