In C#, what does using a dollar sign do in Console.WriteLine [duplicate] - c#-6.0

This question already has answers here:
What does $ mean before a string?
(11 answers)
Closed 6 years ago.
thank you for looking at my question, to verify what i mean
Console.WriteLine($"Hello {variable}");
I am curious to the effect that the $ has on the output from Console.WriteLine

Console.WriteLine($"Hello {variable}");
Is I think equal to:
Console.WriteLine(string.Format("Hello {0}", variable));
It just moves the parameter into the index position as if you were formatting it.

It is a new feature to use in addition to string.Format
It's called Interpolated Strings

Related

What does it mean to initialize a string like "std::string mystring{""};". Is it new feature of C++ 11 or 14? [duplicate]

This question already has answers here:
What are the differences between C-like, constructor, and uniform initialization?
(2 answers)
What are the advantages of list initialization (using curly braces)?
(5 answers)
Closed 3 years ago.
I am new to C++ 11 & 14. In my new role I saw a code where string was initialized (below) and I do not know what is this new way called and where to read about it. Can some one tell what is it called and how does it work. Regards.
std::string mystring{""};
This is initialization with string literal, refer to :https://en.cppreference.com/w/cpp/string/basic_string/basic_string
see Notes.
Your example is same as std:string s{"",0};

In a C Make script, how to increment a variable? [duplicate]

This question already has an answer here:
How to increment variable
(1 answer)
Closed 4 years ago.
I was expecting a function like "increment(VAR)" but couldn't find any.
MATH(EXPR VAR "${VAR}+1")
Review this
How to increment variable
https://cmake.org/cmake/help/v2.8.8/cmake.html#command%3amath
The proffered solution won't work in every context, but only in the context of an ACTION that corresponds to a given target.
Also, not sure what all this MATH jazz is, how about using backticks (prefer $()-notation, but that's ksh-specific):
`expr ${VAR} + 1`
You can barely see the backticks before the 'e' and after the '1', but they're there.

What does ? do in this Ruby expression? [duplicate]

This question already has answers here:
What are the restrictions for method names in Ruby?
(5 answers)
Closed 7 years ago.
On the Chef Style Guide page appears this Ruby expression:
antarctica_hint = hint?('antarctica')
What exactly does the ? after hint and before ('antarctica') mean? Is it just part of the method name? (i.e. the method is called 'hint?' not 'hint')
It is part of method name, and people typically (not always) use it for methods that return boolean value.
An example from Ruby is Class#respond_to?

What is the ruby Regex or String #=== method/operator? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
=== vs. == in Ruby
I can't find verbose docs on this at all. The doc page is broken:
http://ruby-doc.org/core-1.9.3/String.html
The regex page uses the word "case" in two different senses (!) and I can't understand what the point is:
http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-3D-3D
And it was in use in Rails:
https://github.com/rails/rails/commit/3756a3fdfe8d339a53bf347487342f93fd9e1edb?utm_source=rubyweekly&utm_medium=email
=== is the "case equality" operator:
In Ruby, triple equals (Object#===) is, "effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in case statements".
See http://andy-payne.com/2008/09/confusion-over-triple-equals/

What does a single splat/asterisk in a Ruby argument list mean? [duplicate]

This question already has an answer here:
naked asterisk as parameter in method definition: def f(*)
(1 answer)
Closed 10 years ago.
I was poking through the Rails 3 ActiveRecord source code today and found a method where the entire parameter list was a single asterisk.
def save(*)
I couldn't find a good description of what this does (though I have some ideas based on what I know about splat arguments).
What does it do, and why would you use it?
It means it can have any number of arguments (including zero) and it discards all those arguments.

Resources