# Deprecated

**URL:** <https://www.ruby-forum.com/t/deprecated/130161>\
**Category:** Ruby\
**Created:** [February 25, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/deprecated/130161 "2008-02-25T22:26:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [February 25, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/deprecated/130161/1 "2008-02-25T22:26:58Z")

</div>

This just occurred to me (for Java fans):

class Module  
def deprecated \*meths  
meths.each do |me|  
aliased = “_deprecate_#{me}”  
alias\_method aliased, me  
class\_eval “def #{me}(\*a,&b) $stderr.puts ‘WARNING: deprecated  
method called: #{me}’; #{aliased}(\*a,&b) end”  
end  
end  
end

irb(main):010:0\> class String  
irb(main):011:1\> deprecated :to\_i  
irb(main):012:1\> end  
=\> [:to\_i]  
irb(main):013:0\> “123”.to\_i  
WARNING: deprecated method called: to\_i  
=\> 123  
irb(main):014:0\>

Kind regards

robert
