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.

[Resolved] removing a variable from an array

Status
Not open for further replies.
There are a few ways.
Code:
anArray = [0, 1, 2, 3, 4] # => [0, 1, 2, 3, 4]
#removing the last element
anArray.pop # => 4
#removing the first element
anArray.shift # => 0
#removing elements per index
anArray.delete_at(1) # => 2
anArray # => [1, 3]
I suggest reading up on Array here
 
Status
Not open for further replies.

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