The Crystal Programming Language Forum

Assigning named argument to variable of same name does not work

Sorry in advance if this is basic question. I am not sure why the following does not work:

args = %w(-v -F d -f testdump.dump -U curiouslearn -h localhost -p 5432 -d myapp)

Process.run("pg_dump", args = args)

I get Error: expression has no effect.

However, if I change it to the following, it works. Is it not possible to write args = args?

argsval = %w(-v -F d -f testdump.dump -U curiouslearn -h localhost -p 5432 -d myapp)

Process.run("pg_dump", args = argsval)

I think you mean to do args: args. The second example just happens to work because I guess the return value from the assignment is the value.

1 Like

Thank you @Blacksmoke16. I was using the ‘=’ sign. I have not looked at this in a while, and was using the named arguments incorrectly.

1 Like