Inisialisasi Array Multidimensi
- Categories:
- ruby
Array.new memungkinkan untuk menerima block sehingga memungkinkan untuk melakukan inisialisasi Array multidimensi:
# Kode dibawah akan menghasilkan Array dua dimensi
# atau 2 x 2 dan berisi nil
two = Array.new(2) { Array.new(2) }
# => [[nil, nil], [nil, nil]]
# Kode dibawah akan menghasilkan Array empat dimensi
# atau 4 x 4 dan semua elamen berisi 99
four = Array.new(4) { Array.new(4, 99) }
# => [[99, 99, 99, 99], [99, 99, 99, 99], [99, 99, 99, 99], [99, 99, 99, 99]]
- Tags:
- #ruby
Recent Posts
AWS Secrets Manager
Explanation about AWS Secrets Manager with example code.
Envelope Encryption
Envelope encryption is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key.
Tutorial - "su username vs su - username" - A Security Perspective
The main difference between `su username` and `su - username` lies in the environment variables that are loaded when switching to the specified user.
Subdomain Hijacking
My dormant subdomain was recently hijacked, redirecting it to a online gamble registration page.
C# DbContext ServiceLifeTime
my note about C Sharp ServiceLifeTime