summaryrefslogtreecommitdiff
path: root/sample/list.rb
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2020-12-19 15:24:09 +0900
committerKazuhiro NISHIYAMA <zn@mbf.nifty.com>2020-12-19 15:24:09 +0900
commit144b11e03ee0994cacd3fa5eb9ff8b87bd627452 (patch)
tree8ee028eb1f7ef8f4d87f3c083e4577906e7d4cc9 /sample/list.rb
parente64af7d5ad8791cc8fe5ea4e75072e3857bcb270 (diff)
Fix `warning: instance variable @head not initialized` and remove unused instance variable
Diffstat (limited to 'sample/list.rb')
-rw-r--r--sample/list.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/sample/list.rb b/sample/list.rb
index b4d1d65..7458ba0 100644
--- a/sample/list.rb
+++ b/sample/list.rb
@@ -5,7 +5,6 @@ class MyElem
# @variables are instance variable, no declaration needed
@data = item
@succ = nil
- @head = nil
end
def data
@@ -23,6 +22,10 @@ class MyElem
end
class MyList
+ def initialize
+ @head = nil
+ end
+
def add_to_list(obj)
elt = MyElem.new(obj)
if @head