Questions tagged [keyword]

Keywords are special words used as identifiers by a language. They are reserved words accepted by a compiler or interpreter, and thus should not (or cannot) be used as a variable or function name.

Keywords are special words used as identifiers by a language. They are reserved words accepted by a compiler or interpreter, and thus can't be used as a variable or function name. SELECT, for example, is a keyword in SQL, so running an SQL query on a table named SELECT is likely to raise fatal errors.

Often languages provide a method for "escaping" keywords to allow their usage -- for example, the quotation marks in the statement SELECT PERSON_ID FROM "SELECT". But the use of keywords is typically considered bad practice even when a method like this is provided.

The term Keyword is also used as a synonym for "search term". For that meaning, you should use a different tag such as .

2269 questions
1601
votes
19 answers

What is the purpose of the var keyword and when should I use it (or omit it)?

NOTE: This question was asked from the viewpoint of ECMAScript version 3 or 5. The answers might become outdated with the introduction of new features in the release of ECMAScript 6. What exactly is the function of the var keyword in JavaScript,…
Alex
  • 71,233
  • 79
  • 245
  • 337
1042
votes
17 answers

What does 'synchronized' mean?

I have some questions regarding the usage and significance of the synchronized keyword. What is the significance of the synchronized keyword? When should methods be synchronized? What does it mean programmatically and logically?
Johanna
  • 24,844
  • 39
  • 85
  • 114
935
votes
27 answers

What's the difference between the 'ref' and 'out' keywords?

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…
TK.
  • 42,559
  • 46
  • 114
  • 145
906
votes
10 answers

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

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…
delete
717
votes
24 answers

What is the volatile keyword useful for?

At work today, I came across the volatile keyword in Java. Not being very familiar with it, I found this explanation. Given the detail in which that article explains the keyword in question, do you ever use it or could you ever see a case in which…
Richard
  • 9,114
  • 4
  • 24
  • 31
690
votes
7 answers

Equivalent of "continue" in Ruby

In C and many other languages, there is a continue keyword that, when used inside of a loop, jumps to the next iteration of the loop. Is there any equivalent of this continue keyword in Ruby?
Mark Szymanski
  • 50,182
  • 22
  • 66
  • 87
592
votes
6 answers

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

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 <…
Mat
  • 9,423
  • 10
  • 40
  • 48
556
votes
18 answers

Does the 'mutable' keyword have any purpose other than allowing the variable to be modified by a const function?

A while ago I came across some code that marked a member variable of a class with the mutable keyword. As far as I can see it simply allows you to modify a variable in a const method: class Foo { private: mutable bool done_; public: …
Rob
  • 70,036
  • 53
  • 151
  • 189
506
votes
10 answers

What is the native keyword in Java for?

While playing this puzzle (It's a Java keyword trivia game), I came across the native keyword. What is the native keyword in Java used for?
whirlwin
  • 14,425
  • 17
  • 65
  • 90
434
votes
8 answers

What does PHP keyword 'var' do?

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'…
joelpet
  • 4,809
  • 3
  • 18
  • 17
390
votes
4 answers

Passing a dictionary to a function as keyword parameters

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…
Dave Hillier
  • 15,546
  • 8
  • 41
  • 85
318
votes
7 answers

Understanding implicit in Scala

I was making my way through the Scala playframework tutorial and I came across this snippet of code which had me puzzled: def newTask = Action { implicit request => taskForm.bindFromRequest.fold( errors =>…
Clive
  • 3,701
  • 3
  • 15
  • 14
311
votes
13 answers

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

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?
faceless1_14
  • 6,794
  • 9
  • 28
  • 33
305
votes
12 answers

C# : 'is' keyword and checking for Not

This is a silly question, but you can use this code to check if something is a particular type... if (child is IContainer) { //.... Is there a more elegant way to check for the "NOT" instance? if (!(child is IContainer)) { //A little ugly... silly,…
hugoware
  • 33,265
  • 24
  • 58
  • 70
304
votes
10 answers

Normal arguments vs. keyword arguments

How are "keyword arguments" different from regular arguments? Can't all arguments be passed as name=value instead of using positional syntax?
mk12
  • 24,644
  • 29
  • 92
  • 132
1
2 3
99 100