mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-28 00:24:21 +00:00
Add Ruby code blocks to the documents (#1200)
* Add Ruby code blocks to documents * Remove Ruby code from en/docs
This commit is contained in:
@@ -119,14 +119,6 @@ Arrays can be initialized in two ways depending on the needs: either without ini
|
||||
var nums = [_]i32{ 1, 3, 2, 5, 4 };
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="array.rb"
|
||||
# Initialize array
|
||||
arr = Array.new(5, 0) # [ 0, 0, 0, 0, 0 ]
|
||||
nums = [1, 3, 2, 5, 4]
|
||||
```
|
||||
|
||||
### Accessing Elements
|
||||
|
||||
Elements in an array are stored in contiguous memory spaces, making it simpler to compute each element's memory address. The formula shown in the Figure below aids in determining an element's memory address, utilizing the array's memory address (specifically, the first element's address) and the element's index. This computation streamlines direct access to the desired element.
|
||||
|
||||
Reference in New Issue
Block a user