dead code

Discussion in 'Ruby' started by bramu.ss@gmail.com, Mar 29, 2008.

  1. Guest

    Hello,

    I started learning Ruby couple of days back while I am practicing
    some of the examples I saw that Ruby interpreter doesn't warn me if my
    ruby file has dead code. I think its good if Ruby warns me about dead
    code when doing interpretation..

    if true
    puts "its english"
    elsif choice == 2
    puts "my choice is 2"
    end

    in the above code elsif block will never get execute. Please give u r
    views about this...

    Thanks,
    Ramu.
     
    , Mar 29, 2008
    #1
    1. Advertising

  2. Ruby is an interpreted language so it don't check what you write only on
    run-time!

    Writing dead-code is mostly because the programmer is not experimented.
    So instead of adding a feature to analyse/warn which will make ruby more
    slower, it will be better for the programmers to improve theirs skills!

    Regards

    wrote:
    > Hello,
    >
    > I started learning Ruby couple of days back while I am practicing
    > some of the examples I saw that Ruby interpreter doesn't warn me if my
    > ruby file has dead code. I think its good if Ruby warns me about dead
    > code when doing interpretation..
    >
    > if true
    > puts "its english"
    > elsif choice == 2
    > puts "my choice is 2"
    > end
    >
    > in the above code elsif block will never get execute. Please give u r
    > views about this...
    >
    > Thanks,
    > Ramu.
    >
    >
    >
     
    Abdelkader Boudih, Apr 4, 2008
    #2
    1. Advertising

  3. wrote:
    > if true
    > puts "its english"
    > elsif choice == 2
    > puts "my choice is 2"
    > end


    I guess the "correct" answer here would be to write tests for your code.
    If this appeared in a method, and you wrote a test for that method, a
    tool such as 'rcov' would let you know that the 'elsif' is never
    reached.

    Cheers,
    Josh
    --
    Posted via http://www.ruby-forum.com/.
     
    Joshua Ballanco, Apr 4, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. secret

    finding dead code...

    secret, Oct 4, 2003, in forum: Java
    Replies:
    7
    Views:
    1,805
    evernat
    Sep 9, 2009
  2. Geronimo W. Christ Esq

    Removing dead code and unused functions

    Geronimo W. Christ Esq, Jun 19, 2005, in forum: C Programming
    Replies:
    39
    Views:
    2,334
    Dave Thompson
    Jul 4, 2005
  3. Dan Henry
    Replies:
    0
    Views:
    401
    Dan Henry
    Jun 21, 2005
  4. Greg
    Replies:
    10
    Views:
    1,547
    Dave Thompson
    Jul 4, 2005
  5. jaysome

    Dead Code?

    jaysome, Oct 10, 2007, in forum: C Programming
    Replies:
    4
    Views:
    382
    Alan Curry
    Oct 10, 2007
Loading...

Share This Page