Questions tagged [variable-names]

220 questions
6
votes
3 answers

What does the @ in this code sample mean?

Html.TextBox("ParentPassword", "", new { @class = "required" }) what the gosh darned heck is the @ for the @class.
DevelopingChris
  • 36,999
  • 27
  • 83
  • 117
6
votes
13 answers

Really long class/variable/property/method names

Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still…
Zachary Yates
  • 11,664
  • 7
  • 50
  • 84
5
votes
2 answers

ggplot does not work in function, passing in variable names as strings

I have following simple function but its ggplot command does not work. The command works all right when given from command line: > testfn <- function(gdf, first, second){ library(ggplot2) print(ggplot(gdf, aes(first, second)) +…
rnso
  • 20,794
  • 19
  • 81
  • 167
5
votes
5 answers

Append a number in the end of a variable name in java

Suppose that I have a lot of variables defined in my code with names such as this public javax.swing.JPanel BenderPanel1; public javax.swing.JPanel BenderPanel2; public javax.swing.JPanel BenderPanel3; etc... So their general type is like this:…
Theocharis K.
  • 1,221
  • 1
  • 15
  • 41
5
votes
2 answers

Bash command to check if the variable name is valid

#check if the name is valid function myfunc() { #check "${1}" #echo "valid/invalid" } #these should return valid myfunc "my_number" myfunc "my_number1" #these should return ivalid myfunc "1my_number" myfunc "1my _number" myfunc "my…
Lukap
  • 29,596
  • 60
  • 146
  • 239
4
votes
1 answer

Passing variable name as string to function with default parameters

Let’s say there is a debugging function, simplified here as: void DumpString(char* var, char* varname) { printf("%s : '%s'\n", varname, var); } char str[10]="foobar"; DumpString(str, "str"); > str : foobar Let’s make it easier by removing the…
Synetech
  • 8,907
  • 7
  • 59
  • 90
4
votes
1 answer

Single quotes in a variable name in Perl?

I was writing some Perl code in vim and accidentally typed a single quote character in a variable name and noticed that it highlighted it in a different color than normal single quoted strings. I thought that was odd, so I wrote a small test…
tjwrona1992
  • 7,723
  • 5
  • 26
  • 76
4
votes
4 answers

A "nicer" alternative to prefixing local variable names?

In a bunch of code that I'm writing I want to indicate that certain variables are to be used in a certain way, or have a certain characteristic to them. For the sake of discussion, suppose variables can be sweet, salty, sour or bitter. What I use…
einpoklum
  • 86,754
  • 39
  • 223
  • 453
4
votes
1 answer

How to replace only the final character of multiple variable names in R?

Below is some background information about my dataset if you want to understand where my question comes from (I actually want to merge datasets, so maybe somebody knows a more efficient way). The question: How to replace only the final character…
Hannie
  • 407
  • 4
  • 15
4
votes
1 answer

clang unicode characters for variable name

cat test.cpp #include int main() { int à; } results in: clang++ test.cpp test.cpp:4:7: error: expected unqualified-id int à; ^ 1 error generated. Now, is there a way to get clang to allow unicode variable names? Thanks!
anon
  • 36,629
  • 47
  • 184
  • 286
4
votes
1 answer

R - How to get max() to return variable names instead of contents of the variables?

I need to find the max value from a list of variables. However, max() returns the contents of the variable instead of the variable name. Is there a way to get the name instead of the content? Quick example code: jan <- 0 feb <- 0 mar <- 0 #for…
jdfinch3
  • 503
  • 7
  • 18
4
votes
2 answers

Create multiple numbered variables based on a int

How would I create a number of NSDictionary variables using an array's count? This is basically what I came up with, but I'm not sure how to make this work with Objective-C syntax. doesntContainAnother is an NSArray. I want the names of the…
S-T-R-E-G-A
  • 277
  • 3
  • 11
4
votes
4 answers

Do you use particular conventions for naming complementary variables?

I often find myself trying to come up with good names for complementary pairs of variables; where two variables denote opposing concepts, two participants in some sort of duologue, and so on. This might be better explained by a counter-example - I…
Dylan Beattie
  • 50,029
  • 31
  • 120
  • 189
4
votes
3 answers

In Bash, it is okay for a variable and a function to have the same name?

I have the following code in my ~/.bashrc: date=$(which date) date() { if [[ $1 == -R || $1 == --rfc-822 ]]; then # Output RFC-822 compliant date string. # e.g. Wed, 16 Dec 2009 15:18:11 +0100 $date | sed "s/[^ ][^ ]*$/$($date +%z)/" …
davidchambers
  • 20,922
  • 14
  • 68
  • 95
3
votes
1 answer

Neat way to distinguish identifiers and variable names (ANTLR)?

How can we distinguish a variable name, and an identifer, in an ANTLR grammar? VAR: ('A'..'Z')+ DIGIT* ; IDENT : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; The piece of grammar (in ANTLR) does not work because the compiler…
zell
  • 8,226
  • 7
  • 41
  • 91
1 2
3
14 15