3
votes
3answers
50 views

Why is insert/delete on one array modifying another as well?

I have a question about using insert and delete_at with arrays. If I insert an element into an array (arry) and then store that value in a different variable (temp), why does the variable temp change ...
2
votes
1answer
48 views

ruby - can't concatenate array elements into a string?

For personal homework I am trying out a digital clock program to display 'big' numbers. A ruby program that has parts of the clock that come from strings stored in an array and then a routine (not ...
0
votes
2answers
59 views

Algorithm to combine similar hashes in an array

The question is mostly in the title: given an array array = [{x: 1, y: "jacksonville"}, {x: 2, y: "atlanta"}, {x: 1, y: "tampa"}, {x: 2, y: "atlanta"}, {x: 2, y: ...
1
vote
2answers
48 views

How to convert specific format array into hash [closed]

I have an array: ar = ["p=abhZRAh7Un", "a=2", "c=1", "l=3033102", "r=1", "rt=mr", "pid=136330865", "pdid=AiOIhH2vzMPqvhYkxXOxeA%3D%3D", "lks=54.0311", "fks=54.0311"] and need to convert it into a ...
-1
votes
1answer
37 views

parsing yaml in ruby [closed]

If I have a yaml file like so: - name: James categories: "charming fun loving caring smart" description: "Blah blah" - name: Arthur categories: "loving funny smart" description: "Blah ...
1
vote
1answer
32 views

fetch mysql prepared statement as array of hashes

I'm struggling with ruby's mysql gem and prepares statements. I want to end up with the same as I would do with each_hash over the result, but it's nor supported in prepares statements. So I came with ...
-1
votes
1answer
55 views

Looking for hash exercises in ruby [closed]

I'm not sure if I understand hashes and hashes with arrays in the usage setting, where it's being used as a data structure. I've practiced the fundamentals of the key => value and that seems to be ...
4
votes
3answers
55 views

Freezing variables in Ruby don't work

I am learing Ruby, and I just found interesting behaviour when using the Object#freeze method with variables. After I freeze a variable (either Fixnum or Array), I am still able to modify it! It is ...
-1
votes
2answers
39 views

Hash of array dynamic

I have to create an array during runtime which is stored in a hash. How can I achieve this in a smart way ? Following code does not work since services[...] is not an array. services = {} ...
0
votes
3answers
45 views

Ruby: How to store large arrays in code

I have a controller in my rails app. It's a vulnerability scanner in which the signatures are read using nokogiri from an xml file every time the code is executed. This is clearly not the best way to ...
0
votes
1answer
52 views

Array with array of hashes breaks code in ruby

I am new ruby and working on terminal game. I have an array of my deck_of_cards deck_of_cards =[ {:card=>"2C",:value=>2}, {:card=>"3C",:value=>3}, {:card=>"4C",:value=>4}, ...
1
vote
3answers
78 views

Random number generator issues in Ruby

My intention here is just to fill up an array with numbers in order from 1, to a random number between 1 and 1000. However, after repeatedly running this code (about 50 times), the highest number I ...
-2
votes
3answers
69 views

Ruby efficiently determining the largest (longest) of 2 arrays [closed]

I'm trying to efficiently find the largest given two pre-existing arrays. I found many threads on finding the largest value, yet I have not found any specifically about the longest. This is as a ...
0
votes
2answers
36 views

How do I force parsing an XML node as hash array?

This is my simplified myXML: <?xml version="1.0" encoding="utf-8"?> <ShipmentRequest> <Message> <MemberId>A00000001</MemberId> ...
0
votes
2answers
36 views

Hash/Array of objects in Ruby

I'm pretty new to Ruby (I come from a C++ background) and I have an array/hash of objects by their name but I'm having no luck when trying to access their variables. This is my attempt: class Foo ...

1 2 3 4 5 118
15 30 50 per page