Questions tagged [variable-names]

256 questions
2
votes
1 answer

Variable with same name with a struct type compiling only if it's not a template

Why is it allowed to have a variable with same name with a struct type only if it's not a template? Why is this considered okay: struct Foo { int func(int) const; }; struct Foo Foo; but not this: template struct Foo { int…
ofo
  • 1,160
  • 10
  • 21
2
votes
2 answers

Dynamic array name in bash

Because bash doesn't support "arrays in arrays", I'm trying to dynamize variable name when calling arrays. bash version : 4.2 I used this expansion method: https://stackoverflow.com/a/18124325/9336478 #!/bin/bash # data are pre-defined and type is…
Lunartist
  • 394
  • 1
  • 3
  • 9
2
votes
3 answers

How to use variables names as stored in a vector without the quotation marks?

I want to create a loop that stores the output of t-tests for several variables in a data frame. But when I store the different variables in a vector with quotation marks, the variables cannot be used for the t-test as they are saved with the…
Anabel
  • 81
  • 7
2
votes
1 answer

template literals to display the variable name - React.js

In code below I need to display in

a text depending on what props will be passed. If props == "a" text should be from text_a, if props == "b" text from text_b; const Header = (props) => { const text_a = "Lorem ipsum dolor"; const text_b =…

Tomasz
  • 55
  • 4
2
votes
3 answers

Python how to get the value with variable name?

For example, we have the scores of three courses stored in LIST. English, Maths, Physics = 89, 92, 93 LIST = [English, Maths, Physics] for i in range(len(LIST)): print(LIST[i]) And I want the print style to be like English, 89, Maths, 92,…
guorui
  • 871
  • 2
  • 9
  • 21
2
votes
2 answers

R seems to ignore part of variable name after underscore

I encountered a strange problem with R. I have a dataframe with several variables. I add a variable to this dataframe that contains an underscore, for example: allres$tmp_weighted <- allres$day * allres$area Before I do this, R tells me that the…
Lena
  • 311
  • 2
  • 10
2
votes
1 answer

Capitalization after upper-case abbrevation in Go variable name

Should a struct field be named HTTPClient or HTTPclient?
user6216224
2
votes
1 answer

Name a variable with an exclamation in Julia

I got confused about using an exclamation to name a variable in this link. Firstly, it works fine in the JuliaPro Command Prompt Then, I closed the JuliaPro Command Prompt and opened it again, trying to test different variable namings: I could not…
lanselibai
  • 1,203
  • 2
  • 19
  • 35
2
votes
3 answers

Concatenate string literals to generate variable name

Question In python, what is the shortest/easiest way to create a function which allows me to access a variable by concatenating two string literals to generate the variable's name? Background In C, I can do something like so: #define CONCAT(x,y) x…
Cloud
  • 18,753
  • 15
  • 79
  • 153
2
votes
5 answers

is it valid to use standard library function name as identifier in C++?

Consider following program: #include int main() { int printf=9; std::printf("%d",printf); } Is it fine to use built in function name as an identifier in variable declaration? Is this well defined program? I mean is behaviour of…
Destructor
  • 14,123
  • 11
  • 61
  • 126
2
votes
2 answers

Passing variable name as param to function in bash

I am trying to read up 3 similar files with different names to different arrays. Because i didn't want to use unnecessary code i am trying to create functions that would accept array names as params, but i am getting error 'command not…
user2816626
  • 83
  • 1
  • 9
2
votes
1 answer

Create all m-way interactions of n variables in R

I have seven variables and I want to create many new variables, each is an interaction term of the seven variables. There will be 2-way up to 5-way interactions. I plan to do it in two steps. First, create all m-way combination of names of the…
wen
  • 1,875
  • 4
  • 26
  • 43
2
votes
3 answers

Same named variables into different structs

Is it possible to declare variables with the same name into different structs? For example: struct first { int a; int b; int the_same; }; struct second { int x; int y; int the_same };
ᴜsᴇʀ
  • 1,109
  • 2
  • 9
  • 23
2
votes
3 answers

Possible to get the name of a variable in D?

I am currently trying to write a program in D that when called and passed an object, it will serialize the object into an XML document. I would like to make it as simple as passing the object into it, but I'm not entirely sure it can be…
Daniel Martin
  • 570
  • 1
  • 9
  • 18
2
votes
2 answers

XCode find and replace in project problem with XIB

I wanted to rename one badly named variable to something more naturally named (UITableView myListView --> myTableView). Did that with XCode "Edit - Find - Find in project" and replaced all found 7 items with the new one. Application compiled ok,…
JOM
  • 8,139
  • 6
  • 78
  • 111