Questions tagged [syntax]

Syntax refers to the actual language elements and symbols themselves. Questions should be tagged as syntax when the question specifically and almost completely relates to syntax alone. This tag should be used with a specific language tag

syntax
Filter by
Sorted by
Tagged with
3 votes
2 answers
5k views

python string with three dots after newline ... what is this thing?

I just saw this for the first time today. What is this three dots thing called and what is it for? My guess was to help improve readability. Here is the example I saw: g = """ ... S -> NP VP ......
anthonybell's user avatar
  • 5,890
3 votes
2 answers
733 views

Win10 Powershell - Simple If/Elseif Depends on Condition Order?

I'm attempting to write a deployment script that checks the OS major version, then runs command based on that. I can grab that just fine with [System.Environment]::OSVersion.Version.Major, but when I ...
4oo4's user avatar
  • 275
3 votes
1 answer
368 views

Scala extends double arrow

I was looking at the Anorm source code and for the RowParser trait it has the declaration: trait RowParser[+A] extends (Row => SqlResult[A]) { ... } I was curious what type (Row => SqlResult[A]...
cdmckay's user avatar
  • 32.1k
3 votes
2 answers
16k views

How to pass JSON (string data) to PowerShell?

I'm passing the following as an argument to powershell (v4 on w7): -debugWrite -fileName SettingsFile -jsonContent { "c": "some setting", "d": "unknown", "b": "some thing", "a": 1 } But PS gets ...
Yumi Koizumi's user avatar
3 votes
1 answer
3k views

Why does method-call on ambiguous numeric cause error?

In the reference at Literal expressions, I see If the token has no suffix, the expression's type is determined by type inference: ... If the program context under-constrains the type, it defaults to ...
Hiroto Kagotani's user avatar
3 votes
1 answer
4k views

What do greater/less than sign (e.g. Action<List<X>>) mean in C#?

example: public event Action<List<WKSProfile>> WorkstationProfileChanged; I have trouble understanding the the above member. Does it imply that it returns : Action<List<...
Nik's user avatar
  • 334
3 votes
2 answers
2k views

What is the syntax for an if-let statement?

I encountered this snippet in some example code. It works fine, but I got a linter error saying that it should be structured as an if-let statement. match event { glutin::Event::WindowEvent { ...
BonsaiOak's user avatar
  • 28.5k
3 votes
4 answers
231 views

Why list monad combines in that order?

I was reading about list monads and encountered: [1,2] >>= \n -> ['a','b'] >>= \ch -> return (n,ch) it produces [(1,'a'),(1,'b'),(2,'a'),(2,'b')] Here's how I understand it: ...
user avatar
3 votes
1 answer
244 views

Why can't I access a member of this class? [duplicate]

I have the following three class definitions: class String { public: String() {} String(const char *) {} }; class ClassA { public: ClassA(const String &) {} }; ...
Nathan Osman's user avatar
  • 72.3k
3 votes
1 answer
635 views

Wordpress Syntax Error, unexpected [

I have a problem with a wordpress installation. When I work locally, this function works properly: function get_images_from_media_library() { $args = array( 'post_type' => 'attachment', '...
Joshua Soileau's user avatar
3 votes
2 answers
463 views

What is <<- in ruby?

From the Ruby_Newbie Guide to Symbols: Author is trying to show a simplified implementation of the attr_writer method. #!/usr/bin/env ruby def make_me_a_setter(thename) eval <<-SETTERDONE ...
user's user avatar
  • 3,436
3 votes
4 answers
1k views

How do I assign the output from a Matlab function to a variable in a single line?

Is there a way in matlab to assign the output from a function in matlab to a vector within a single line? For example, this function should assign a perimeter and an area value function [p,a] = ...
Arlo Olson's user avatar
3 votes
2 answers
12k views

Using Greek alphabet (or any non-ANSI alphabet) as variable names in MATLAB

Is it possible using Greek alphabet to represent variables in MATLAB? For example, I'd like to use the Greek character epsilon as a variable in MATLAB. I tried to insert \epsilon but I received an ...
user1508419's user avatar
3 votes
4 answers
30k views

DB2 for IBM iSeries: IF EXISTS statement syntax

I am familiar with Sybase which allows queries with format: IF EXISTS () THEN ... ELSE ... END IF (or very close). This a powerful statement that allows: "if exists, then update, else insert". I am ...
kevinarpe's user avatar
  • 20.9k
3 votes
3 answers
193 views

where is the documentation for Array()? [closed]

Browsing the ruleby source code, I noticed that they were calling Container(:and), which is something I rarely see. In fact, the only other place I've seen it is in the fabrication gem A quick look ...
rm-rf's user avatar
  • 1,323
3 votes
2 answers
412 views

What does ::template mean other than making TMP compile [duplicate]

Possible Duplicate: Using template parameters as template parameters Here's a code snippet of some heavily templated container classes used to bind an arbitrary amount of fields of arbitrary ...
AJG85's user avatar
  • 16k
3 votes
2 answers
366 views

When can `typename` be used with identifiers that unambiguously refer to a type?

Normally, typename is used to disambiguate between cases where an identifier may refer to a type, or may refer to something else: template<class T> void foo(typename T::type value) { // ... }...
Alecto Irene Perez's user avatar
3 votes
5 answers
20k views

PHP code to convert PHP to JS [closed]

I need some PHP code to convert some PHP into JS. functionality - I'm using common PHP functions from php.js syntax - ??? The issue is converting the syntax. I don't need full PHP syntax, mind you; ...
Christian's user avatar
  • 27.9k
3 votes
4 answers
1k views

PHP: less ugly syntax for named parameters / arrays?

Here's what I am trying to accomplish: function foo($args) { switch($args['type']) { case 'bar': bar($args['data']); // do something break; } } // or something like that Which is ...
quantumSoup's user avatar
  • 27.7k
3 votes
2 answers
23k views

Android intent syntax

In my attempts to find out how to start a new intent in my app, I've come across several ways of phrasing it. This syntax returns a runtime error, namely a ActivityNotFound exception Intent in = new ...
hacke's user avatar
  • 289
3 votes
2 answers
291 views

Rationale behind static const (non-integral) member initialization syntax?

I know how to initialize a static member that's not an integer, but I'm wondering, what is the rationale behind the syntax for this? I'd like to be able to just put the value in the class, like you ...
sje397's user avatar
  • 41.6k
3 votes
5 answers
7k views

C++: Syntax error C2061: Unexpected identifier

What's wrong with this line of code? bar foo(vector ftw); It produces error C2061: syntax error: identifier 'vector'
Nick Heiner's user avatar
3 votes
4 answers
1k views

What does JavaScript >> stand for? [duplicate]

I'm translating a JavaScript algorithm into PHP, and I ran into the symbol >>, and I have no clue what it means. It's hard to search Google for symbols, so can anyone tell me what it means?
Dan's user avatar
  • 817
3 votes
3 answers
276 views

What does the syntax mean in Java: new Stream<Integer>(){ ... }?

I have encountered the following Java syntax that I don't recognize. This part is fine: public abstract class Stream<T> implements Iterator<T> { public boolean hasNext() { ...
lali's user avatar
  • 33
3 votes
1 answer
1k views

Regarding implementation of multi component dependent uipickerview

I am having trouble grasping the concept of multi component uipickerviews. I really would like to just OWN this subject. I would like to make a 4 component pickerview with components that are ...
Jeff's user avatar
  • 57
3 votes
3 answers
2k views

Is a semicolon required before a function closure in javascript?

I'm wondering if this is a compiler bug, or this is the way it's supposed to be. Using node.js v10.15.3, this code throws an error: var x x = false (function y() { console.log('foo') }()) But this ...
Duncan's user avatar
  • 507
3 votes
1 answer
3k views

JQuery - $.when syntax for array of Deferred objects [duplicate]

It is the first time I am using $.when and I am having difficulty with the syntax. I have code similar to simplified example below. It works (if I haven't caused an error when I simplified it). My ...
Philip Fourie's user avatar
3 votes
5 answers
22k views

Converting loops (Java Beginner question)

Does Converting between loops always works like this? or there is some situation that it does not? and what is the fastest way to check while I'm solving a question like this in Exam? For Loop: for(...
Mohammad Fadin's user avatar
3 votes
6 answers
870 views

C++ Pointer in Function

I know that technically all three ways below are valid, but is there any logical reason to do it one way or the other? I mean, lots of things in c++ are "technically valid" but that doesn't make them ...
Adam's user avatar
  • 647
3 votes
5 answers
502 views

Call methods on native Javascript types without wrapping with ()

In Javascript, we can call methods on string literals directly without enclosing it within round brackets. But not for other types such as numbers, or functions. It is a syntax error, but is there a ...
Anurag's user avatar
  • 141k
3 votes
5 answers
2k views

PHP Alternative Control Structures, any drawbacks?

I've been working with PHP code that generates HTML without any templating, and it's quite spaghetti and difficult to read with the way they've structured it. One way to drastically improve following ...
Kristopher Ives's user avatar
3 votes
5 answers
323 views

Am I missing anything here in my statement about c++?

You can't have code outside of functions except for declarations, definitions and preprocessor directives. Is that statement accurate, or is there something I'm missing? I'm teaching my nephew to ...
Benjamin Lindley's user avatar
2 votes
4 answers
4k views

I get these weird characters when I try to print out a vector element! [duplicate]

I'm using Netbeans. When I run the program below, I get this as output [I@de6ced! How come? import java.util.Arrays; import java.util.Vector; public class Test { public static void main (String[] ...
user126356's user avatar
2 votes
2 answers
2k views

String interpolation C#: Documentation of colon and semicolon functionality

I found this codegolf answer for the FizzBuzz test, and after examining it a bit I realized I had no idea how it actually worked, so I started investigating: for(int i=1; i<101;i++) System....
Jon Barker's user avatar
  • 1,799
2 votes
1 answer
843 views

Convert RegEx from JavaScript to Java

OK, so I am trying to split a String by ", " which are not inside '[' or ']'. I have a working RegEx for JavaScript but have been unable to convert it to Java syntax. JS RegEX: /,(?![^[]*])/...
helfo's user avatar
  • 119
2 votes
1 answer
3k views

Python - Syntax error on colon in list

I've been trying to create a simple dictionary to define a word that the user inputs. After defining the dictionary and it's words, I'm trying to print the definition of the input'd word. For some ...
Harry's user avatar
  • 37
2 votes
2 answers
694 views

Is not using & with a variable in scanf() a syntax error or a runtime error?

I was taught that a syntax error comes from a single mistake and doesn't execute the program. However, a runtime error still starts the program but crashes in the middle. If I accidentally didn't put &...
Chanyoung Nathan Lee's user avatar
2 votes
1 answer
4k views

Is there a syntax for wildcard export as? [duplicate]

There is the import syntax: import * as foo from 'bar'; I similarly tried: export * as foo from 'bar'; but that threw the errors: ERROR in src/app/@theme/components/aComp/aComp.loader.ts(1,10): ...
Nae's user avatar
  • 15k
2 votes
1 answer
193 views

Why does the order of operands matter when testing for property of PSCustomObject

I have tried both cases $psCustomObject.x -eq $null and $null -eq $psCustomObject.x in an if statement and only the latter passed the if. Why does this behave this way? It seems illogical. My ...
Preza8's user avatar
  • 398
2 votes
2 answers
493 views

Printing the argument in powershell

May I know, why the string argument is not printed in the following powershell script? function Get-Name ( [string] $Username ) { echo "user : $Username" } PS C:\> .\Get-Name.ps1 -username "...
mahmood's user avatar
  • 24k
2 votes
3 answers
6k views

Putting loop inside C macro

I'm looking for a way to convert the following function structure to a macro. I know, it's a silly and pointless example, but it illustrates the point since I cannot give out my actual source code. ...
audiFanatic's user avatar
  • 2,416
2 votes
1 answer
703 views

Simple javascript IF statement - what is the correct syntax?

Suppose I have this URL: www.example.com/product-p/xxx.htm The following javascript code picks out the phrase product-p from the URL: urlPath = window.location.pathname; urlPathArray = urlPath....
ghilton's user avatar
  • 127
2 votes
2 answers
3k views

Problems with Xcode Syntax Highlighting

In Xcode 3.2.1 I have this problem where it stops highlighting Objects in purple, and such. For example: In that example, NSAutoreleasePool, pool, img, size, width and height should be highlighted, ...
skylerl's user avatar
  • 4,110
2 votes
3 answers
387 views

php: Are there great reasons to quote all array keys/indexes?

I'm running through someone else's code, and they constantly avoid escaping their array keys. For example: $row_rsCatalogsItems[Name] instead of $row_rsCatalogsItems['Name'] so I'm constantly ...
Kzqai's user avatar
  • 22.9k
2 votes
3 answers
8k views

Double For Loop syntax in C

I am new to C and have to write some code that emulates a given function. However, I am having a difficult time understanding what the second for loop in this code is doing, explicitly. The syntax ...
Joseph's user avatar
  • 321
2 votes
3 answers
261 views

How to launch a function template with many boolean arguments without 2^n if statements

I have a CUDA (C++) code that uses function templates exclusively for performance reasons, so that the function will do only what it needs to do and not constantly be loading and reading booleans to ...
Agade's user avatar
  • 515
2 votes
5 answers
329 views

What is the role of the data types inside of < > in Java? [duplicate]

Possible Duplicate: Java Generics To be more specific, whats the role of the <String> in the following line of code? private List<String> item = new ArrayList<String>();
Emanuil Rusev's user avatar
2 votes
2 answers
6k views

Printing the addresses of variables in decimal

I'm trying to print the addresses of the elments of an array in decimal instead of hexa but it doesn't work. Below is the code and output example. #include <iostream> #include <iomanip> ...
shinzou's user avatar
  • 6,030
2 votes
2 answers
2k views

What does this syntax mean in Python?

What does the comma in the declaration below mean? Does it define two variables at once? resp, content = client.request(request_token_url, "GET")
charliesneath's user avatar
2 votes
4 answers
254 views

why MyClass.class exists in java and MyField.field isn't?

Let's say I have: class A { Integer b; void c() {} } Why does Java have this syntax: A.class, and doesn't have a syntax like this: b.field, c.method? Is there any use that is so common for ...
oshai's user avatar
  • 15.2k

1
28 29
30
31 32
57