syntax

What is the difference between the non-generic IEnumerable and the generic IEnumerable<T>?

匆匆过客 提交于 2020-01-21 01:46:06
问题 Sorry for such a vague question, but I have been searching around for the best part of a day, I have read article after article (and many questions here) but just cannot find an easy to understand answer. I (think I) know what IEnumerable is for, but I just can't understand what it means when it is defined with a generic type argument, for example: IEnumerable<int> test = method(); This is just driving me mad! Please put me out of misery and explain what it means? 回答1: An IEnumerable is

Captureless lambda cannot be converted to function pointer when stored in std::function

我只是一个虾纸丫 提交于 2020-01-21 01:14:29
问题 Usually, a C++ lambda without a capture should be convertable to a c-style function pointer. Somehow, converting it using std::function::target does not work (i.e. returns a nullptr), also the target_type does not match the signature type even though it seems to be the same. Tested on VC13 and GCC 5.3 / 5.2.0 / 4.8 Minimal testing example: #include <functional> #include <iostream> void Maybe() { } void callMe(std::function<void()> callback) { typedef void (*ftype)(); std::cout << (callback

What do parentheses in binding paths mean?

蹲街弑〆低调 提交于 2020-01-20 04:07:59
问题 Recently i've read 'Databinding overview' article at MSDN and there is such sample code: <TextBox.ToolTip> <Binding RelativeSource="{RelativeSource Self}" Path="(Validation.Errors)[0].ErrorContent"/> </TextBox.ToolTip> I know that {} means markup extensions but what mean () parentheses here? It would be nice someone share link to explanation such syntax. Thanks! Path="(Validation.Errors)[0].ErrorContent" 回答1: The () parentheses refer to Attached Properties. Binding to an Attached Property 回答2

What do parentheses in binding paths mean?

大憨熊 提交于 2020-01-20 04:07:08
问题 Recently i've read 'Databinding overview' article at MSDN and there is such sample code: <TextBox.ToolTip> <Binding RelativeSource="{RelativeSource Self}" Path="(Validation.Errors)[0].ErrorContent"/> </TextBox.ToolTip> I know that {} means markup extensions but what mean () parentheses here? It would be nice someone share link to explanation such syntax. Thanks! Path="(Validation.Errors)[0].ErrorContent" 回答1: The () parentheses refer to Attached Properties. Binding to an Attached Property 回答2

What is bang dollar (!$) in Bash?

China☆狼群 提交于 2020-01-20 01:17:11
问题 Bang dollar seems to refer to the last part of the last command line. E.g. $ ls -l .... something $ !$ -l bash: -l command not found I can find plenty on the dollar variables (e.g. $! ) but not on this. Any explanation? 回答1: That's the last argument of the previous command. From the documentation: !!:$ designates the last argument of the preceding command. This may be shortened to !$ . Remark. If you want to play around with Bash's history, I suggest you turn on the shell option histverify

Use-case of `oneway void` in Objective-C?

纵饮孤独 提交于 2020-01-19 06:28:25
问题 I found a strange keyword in NSObject.h - (oneway void)release; I searched the web, and learned it relates to asynchronous message passing, which looks similar with Erlang's message passing. It seems this can make many interesting things. What are some good use-cases of this keyword? 回答1: oneway is used with the distributed objects API, which allows use of objective-c objects between different threads or applications. It tells the system that it should not block the calling thread until the

What does the curly-brace syntax ${var%.*} mean?

天大地大妈咪最大 提交于 2020-01-19 05:19:08
问题 I was reviewing some of my old code and came across this syntax: extractDir="${downloadFileName%.*}-tmp" The only information I found searching refers to a list of commands, but this is just one variable. What does this curly-brace syntax mean in bash? 回答1: In this context, it is a parameter substitution. The ${variable%.*} notation means take the value of $variable , strip off the pattern .* from the tail of the value — mnemonic: percenT has a 't' at the Tail — and give the result. (By

What does the curly-brace syntax ${var%.*} mean?

别来无恙 提交于 2020-01-19 05:19:05
问题 I was reviewing some of my old code and came across this syntax: extractDir="${downloadFileName%.*}-tmp" The only information I found searching refers to a list of commands, but this is just one variable. What does this curly-brace syntax mean in bash? 回答1: In this context, it is a parameter substitution. The ${variable%.*} notation means take the value of $variable , strip off the pattern .* from the tail of the value — mnemonic: percenT has a 't' at the Tail — and give the result. (By

Is there an “opposite” to the null coalescing operator? (…in any language?)

坚强是说给别人听的谎言 提交于 2020-01-19 04:43:07
问题 null coalescing translates roughly to return x, unless it is null, in which case return y I often need return null if x is null, otherwise return x.y I can use return x == null ? null : x.y; Not bad, but that null in the middle always bothers me -- it seems superfluous. I'd prefer something like return x :: x.y; , where what follows the :: is evaluated only if what precedes it is not null . I see this as almost an opposite to null coalescence, kind of mixed in with a terse, inline null-check,