Skip to content

Commit

Permalink
Create warn_array_primitives.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrawl authored Oct 29, 2023
1 parent fc16680 commit 6b667e3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/API/runtime/warn_array_primitives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# warn_array_primitives!

This function helps you audit your game of usages of array-based primitives. While array-based primitives are simple to create and use, they are slower to process than Hash or Class based primitives.

```ruby
def tick args
# enable array based primitives warnings
args.gtk.warn_array_primitives!

# array-based primitive elsewhere in code
# an log message will be posted giving the location of the array
# based primitive usage
args.outputs.sprites << [100, 100, 200, 200, "sprites/square/blue.png"]

# instead of using array based primitives, migrate to hashes as needed
args.outputs.sprites << {
x: 100,
y: 100,
w: 200,
h: 200, path:
"sprites/square/blue.png"
}
end
```

0 comments on commit 6b667e3

Please sign in to comment.