keyword

What is the “continue” keyword and how does it work in Java?

会有一股神秘感。 提交于 2019-11-26 01:25:42
问题 I saw this keyword for the first time and I was wondering if someone could explain to me what it does. What is the continue keyword? How does it work? When is it used? 回答1: A continue statement without a label will re-execute from the condition the innermost while or do loop, and from the update expression of the innermost for loop. It is often used to early-terminate a loop's processing and thereby avoid deeply-nested if statements. In the following example continue will get the next line,

Is there a goto statement in Java?

橙三吉。 提交于 2019-11-26 01:22:20
问题 I\'m confused about this. Most of us have been told that there isn\'t any goto statement in Java. But I found that it is one of the keywords in Java. Where can it be used? If it can not be used, then why was it included in Java as a keyword? 回答1: The Java keyword list specifies the goto keyword, but it is marked as "not used". It was in the original JVM (see answer by @VitaliiFedorenko), but then removed. It was probably kept as a reserved keyword in case it were to be added to a later

When were the 'and' and 'or' alternative tokens introduced in C++?

家住魔仙堡 提交于 2019-11-26 01:08:32
问题 I\'ve just read this nice piece from Reddit. They mention and and or being \"Alternative Tokens\" to && and || I was really unaware of these until now. Of course, everybody knows about the di-graphs and tri-graphs, but and and or ? Since when? Is this a recent addition to the standard? I\'ve just checked it with Visual C++ 2008 and it doesn\'t seem to recognize these as anything other than a syntax error. What\'s going on? 回答1: MSVC supports them as keywords only if you use the /Za option to

Python's equivalent of && (logical-and) in an if-statement

 ̄綄美尐妖づ 提交于 2019-11-26 01:04:04
问题 Here\'s my code: def front_back(a, b): # +++your code here+++ if len(a) % 2 == 0 && len(b) % 2 == 0: return a[:(len(a)/2)] + b[:(len(b)/2)] + a[(len(a)/2):] + b[(len(b)/2):] else: #todo! Not yet done. :P return I\'m getting an error in the IF conditional. What am I doing wrong? 回答1: You would want and instead of && . 回答2: Python uses and and or conditionals. i.e. if foo == 'abc' and bar == 'bac' or zoo == '123': # do something 回答3: Two comments: Use and and or for logical operations in Python

Git equivalent of subversion's $URL$ keyword expansion

自古美人都是妖i 提交于 2019-11-26 01:02:45
问题 I am considering migrating from subversion to git. One of the things we use subversion for our sysadmins to manage things like configuration files. To that end, we put $URL$ into each file, which expands to the file\'s location in the subversion tree. This lets the admins look at a file on some arbitrary host and figure out where in the tree it came from. The closest analog I could find is gitattributes. There is the filter= directive, but it seems that git doesn\'t communicate to the filter

Using the keyword “this” in java [duplicate]

谁说我不能喝 提交于 2019-11-26 01:00:08
问题 This question already has an answer here: When should I use “this” in a class? 17 answers I\'m trying to get an understanding of what the the java keyword this actually does. I\'ve been reading Sun\'s documentation but I\'m still fuzzy on what this actually does. 回答1: The this keyword is a reference to the current object. class Foo { private int bar; public Foo(int bar) { // the "this" keyword allows you to specify that // you mean "this type" and reference the members // of this type - in

What does PHP keyword 'var' do?

混江龙づ霸主 提交于 2019-11-26 00:46:28
问题 This is probably a very trivial question, but I haven\'t been able to find the answer neither through web search engines, nor on php.net. Please just direct me to where I can read about this, if you haven\'t got time to explain. What does the \'var\' keyword mean in PHP? Are there any differences between PHP4 and PHP5? 回答1: It's for declaring class member variables in PHP4, and is no longer needed. It will work in PHP5, but will raise an E_STRICT warning in PHP from version 5.0.0 up to

Passing a dictionary to a function as keyword parameters

倖福魔咒の 提交于 2019-11-26 00:35:56
问题 I\'d like to call a function in python using a dictionary. Here is some code: d = dict(param=\'test\') def f(param): print(param) f(d) This prints {\'param\': \'test\'} but I\'d like it to just print test . I\'d like it to work similarly for more parameters: d = dict(p1=1, p2=2) def f2(p1, p2): print(p1, p2) f2(d) Is this possible? 回答1: Figured it out for myself in the end. It is simple, I was just missing the ** operator to unpack the dictionary So my example becomes: d = dict(p1=1, p2=2)

Difference of keywords 'typename' and 'class' in templates?

假如想象 提交于 2019-11-25 23:47:58
问题 For templates I have seen both declarations: template < typename T > template < class T > What\'s the difference? And what exactly do those keywords mean in the following example (taken from the German Wikipedia article about templates)? template < template < typename, typename > class Container, typename Type > class Example { Container< Type, std::allocator < Type > > baz; }; 回答1: typename and class are interchangeable in the basic case of specifying a template: template<class T> class Foo

What&#39;s the difference between the &#39;ref&#39; and &#39;out&#39; keywords?

半腔热情 提交于 2019-11-25 23:28:41
问题 I\'m creating a function where I need to pass an object so that it can be modified by the function. What is the difference between: public void myFunction(ref MyClass someClass) and public void myFunction(out MyClass someClass) Which should I use and why? 回答1: ref tells the compiler that the object is initialized before entering the function, while out tells the compiler that the object will be initialized inside the function. So while ref is two-ways, out is out-only. 回答2: The ref modifier