Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

simple loop issue

so what i wanna do is eliminate the nil values. but my problem is im not sure how to handle two nil values in a row. here is what i have

Code:
 

for i in 1...array

    if array[i] == nil

       i +=1

    end

    #do the rest of the method, the error would be here because the second nil value made it through.

end

 

i know this is so simple but its driving me crazy
 
Well, let's say it's a hash, it'd be done like this...

some_hash.delete_if {|k,v| v.nil?}
#=> all key-value pairs that weren't deleted

Just check if RGSS includes that method.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top