•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 375,249 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,147 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Views: 3195 | 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: 481
Reputation:
Rep Power: 3
Solved Threads: 31
•
•
•
•
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: 481
Reputation:
Rep Power: 3
Solved Threads: 31
•
•
•
•
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)
•
•
•
•
•
•
•
•
DaniWeb Ruby Marketplace
- need help with learning ruby (Ruby)
- Anyone want to learn Ruby (Ruby)
Other Threads in the Ruby Forum
- Previous Thread: Ruby, Rails Job sites - Resource
- Next Thread: What do you think of Ruby?


Linear Mode