Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Views: 3933 | Replies: 5 | Solved
![]() |
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
•
•
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation:
Rep Power: 4
Solved Threads: 34
•
•
•
•
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
For some reason the rubycentral site seems to be down so the original article I'd link to isn't available, however it's in the google cache.
Note to self... pocket cup
•
•
Join Date: Apr 2007
Location: Pune, India
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 1
•
•
•
•
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
You can read this small tutorial here -
http://sitekreator.com/satishtalim/o...alization.html
Hope that helps.
Thanks, these sites really helped a lot and answered my questions, but the last one also brought up one little one: in the second example the programmer used What does the string do and do please? Thanks once again for any help.
File.open('game', 'w+') do |f|•
•
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation:
Rep Power: 4
Solved Threads: 34
•
•
•
•
Thanks, these sites really helped a lot and answered my questions, but the last one also brought up one little one: in the second example the programmer usedWhat does the string do and do please? Thanks once again for any help.File.open('game', 'w+') do |f|
"w+" is a mode string; it truncates the file (or creates a new one if it doesn't exist)
|f| is a block. Basically it means that in the following code f refers to the file.
A quick example of a simple block:
>> 5.times do |i| ?> puts i.to_s >> end 0 1 2 3 4 => 5
Note to self... pocket cup
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode