Skip to content

Commit d1a604e

Browse files
committed
Update README.md
1 parent 14484c2 commit d1a604e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Weakref
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/weakref`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
Weak Reference class that allows a referenced object to be
4+
garbage-collected.
45

5-
TODO: Delete this and the text above, and describe your gem
6+
A WeakRef may be used exactly like the object it references.
67

78
## Installation
89

@@ -22,7 +23,14 @@ Or install it yourself as:
2223

2324
## Usage
2425

25-
TODO: Write usage instructions here
26+
```ruby
27+
foo = Object.new # create a new object instance
28+
p foo.to_s # original's class
29+
foo = WeakRef.new(foo) # reassign foo with WeakRef instance
30+
p foo.to_s # should be same class
31+
GC.start # start the garbage collector
32+
p foo.to_s # should raise exception (recycled)
33+
```
2634

2735
## Development
2836

@@ -32,4 +40,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3240

3341
## Contributing
3442

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/weakref.
43+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/weakref.

0 commit comments

Comments
 (0)