Is it possible to put an "if statement" inside a "N.times{}" bracket in Ruby?
IN RUBY,
for example, if you wanted to print the first 25 integers, and put ", " between the 1st and last integers in the output (to clean it up a little bit), could you write something like the code below? (I deliberately didn't use while/for loops.)


    N = 25
    
    N.times{|i| print("#{i}")
     if i > 0 and i < 25
       print ", "
    }

If this has already been answered, please redirect me to the old post? Thanks :)
Is it possible to put an "if statement" inside a "N.times{}" bracket in Ruby?
===

IN RUBY,
for example, if you wanted to print the first 25 integers, and put ", " between the 1st and last integers in the output (to clean it up a little bit), could you write something like the code below? (I deliberately didn't use while/for loops.)


    N = 25
    
    N.times{|i| print("#{i}")
     if i > 0 and i < 25
       print ", "
    }

If this has already been answered, please redirect me to the old post? Thanks :)