Questions tagged [anonymous-arrays]
8 questions
6
votes
4 answers
How to create an anonymous array ([]) with 'empty slots'?
I can create an array with 'empty slots' in it:
$ perl -wde 1
...
DB<1> $x[2] = 0
DB<2> x \@x
0 ARRAY(0x103d5768)
0 empty slot
1 empty slot
2 0
or
DB<3> $#y = 4
DB<4> x \@y
0 ARRAY(0x103d5718)
0 empty slot
1 empty…

hexcoder
- 1,218
- 8
- 13
4
votes
1 answer
Cast anonymous two-dimensional array
Is it possible to create an anonymous array like this?
char **values = (*char[]){"aaa", "bbb", "ccc"};
This method works:
char **values
char *tmp[] = {"aaa", "bbb", "ccc"};
values = tmp;

bartool
- 43
- 4
2
votes
6 answers
Anonymous array indexing instead of a switch statement?
In Java, I find the following code much cleaner and easier to maintain than the corresponding bulky switch statement:
try {
selectedObj = new Object[] {
objA,
objB,
objC,
objD,
}[unvalidatedIndex];
} catch…

Blagovest Buyukliev
- 42,498
- 14
- 94
- 130
1
vote
4 answers
Perl: String to anonymous array?
SOLVED ALREADY --> See edit 7
At this moment I'm fairly new on Perl, and trying to modify part of an existing page (in Wonderdesk).
The way the page works, is that it gets the information from the GET url and parses it to an SQL query.
Since this is…

Master-Guy
- 176
- 8
0
votes
1 answer
Mustache Java: Iterating over an anonymous/keyless/top-level array
Question: How to iterate over an array read from json input, that does not have a variable name/key.
I did not want to restructure the json file as I'd have to edit the service which generates this json and also other services rely on this file and…

J. Doe
- 142
- 1
- 14
0
votes
2 answers
Anonymous array accepting null values for int
InquiryOrder Model
public class InquiryOrder
{
[Key]
public int InquiryOrderId { get; set; }
public string InquiryOrderName { get; set; }
[ForeignKey("ProductType")]
public int? ProductTypeId { get; set; }
public virtual…

Isuru
- 950
- 1
- 13
- 34
-1
votes
2 answers
How can I get the last and current element of an anonymous-array?
How can I get the last and current element of an array?
Getting the current element of my array, seems pretty easy, if i get it via [$i]
print " Atm: ",$king->[$i]->{hit},
But how does this work for the element before? Is there some simple way to…

user2525078
- 53
- 7
-2
votes
1 answer
why there is no issue when anonymous array reference to Object class object
Below expression is having no issue-
Object obj = new int[] { 1, 2, 3 };
but below two have compile time issue-
Integer i = new int[] { 1, 2, 3 };
int j = new int[] {1,2,3};
why?