Questions tagged [variable-names]

256 questions
6
votes
2 answers

Create a dynamic variable reference in Typescript

Thanks ahead of time, to anyone who helps. :) This may seem a simple answer to those who are experienced, but I have scoured the internet as well as a couple of reference books, and not found a straight forward answer to this question, so hopefully…
wdlee
  • 73
  • 1
  • 1
  • 5
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
  • 39,797
  • 30
  • 87
  • 118
5
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
  • 8,614
  • 8
  • 35
  • 98
5
votes
2 answers

Why don't these Unicode variable names work with -fextended- identifiers? «, » and ≠

I heard that it is possible to use Unicode variable names using the -fextended-identifiers flag in GCC. So I made a test program in C++, but it does not compile. #include #include #define ¬ ! #define ≠ != #define « << #define »…
wefwefa3
  • 3,872
  • 2
  • 29
  • 51
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
  • 23,686
  • 25
  • 112
  • 234
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,281
  • 1
  • 16
  • 43
5
votes
4 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
  • 31,523
  • 64
  • 157
  • 244
5
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
  • 23,918
  • 16
  • 76
  • 105
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
  • 9,643
  • 9
  • 64
  • 96
4
votes
2 answers

How to uppercase '$*' value from makefile target?

I have a bunch of targets, each for a different shell as follow: BASH_VERSION := 4.4 FISH_VERSION := 3.0.0 … ZSH_VERSION := 5.4.2-r1 .PHONY: dev-pure-on-bash dev-pure-on-bash: $(MAKE) dev-pure-on TARGET=bash VERSION="${BASH_VERSION}"…
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
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
  • 118,144
  • 57
  • 340
  • 684
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
  • 417
  • 5
  • 17
4
votes
3 answers

Extract variable names from list or vector in R

Assuming: aa = c('A','B','C') bb = c('D','E','F') list1 = list(aa,bb) vect1 = c(aa,bb) Is there a way to extract the variable names as strings ('aa', 'bb') from either list1 or vect1? Is this information being stored in lists and vectors? If not,…
Daan11
  • 67
  • 1
  • 2
  • 7
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
  • 41,035
  • 53
  • 197
  • 293
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
  • 513
  • 1
  • 7
  • 18
1 2
3
17 18