FAQ Database Discussion Community


Error when summing variable and number inside brackets NoMethodError

ruby,syntax,brackets
I don't know why the error mentioned below happens. It is caused because I use a variable and summing it with a number inside the brackets. How can I fix it? Any help would be greatly appreciated. I have spent much time searching for the answer but I couldn't find...

Does “Text” in the HTML5 syntax mean “any character”?

html,html5,text,syntax
I wasn't able to find any restrictions what characters are allowed in Text does this imply that erverthing is allowed or are there restrictions that affect HTML documents in general? For example the Character Reference Section states that: The numeric character reference forms [...] are allowed to reference any Unicode...

Syntax error python 2.7 [closed]

python,syntax,flask,pydub
Im have syntax error in def reverse app.route i know there is something wrong with getAudio but i dont know what. Here is example from pydub documentation sound1 = AudioSegment.from_file("/path/to/sound.wav", format="wav") And heres part of my code, commented @app.route('/Path/<filename>') def getFilePath(filename): return os.path.join(os.path.dirname(__file__), 'files', filename) @app.route('/Audio/<filename>') def getAudio(filename): return AudioSegment.from_file(getFilePath(filename,...

C# No value given for one or more required parameters

c#,sql,syntax,ms-access-2007,helper
Is there anything Wrong in SQL Syntax ? Sql syntax : UPDATE Table1 SET Username='Diana' , Email='[email protected]' , FirstName='' , LastName='' , CrediCardNum='' Where Username='Diana' it Keeps Giving me the Error: No value given for one or more required parameters. I tried restarting visual studio but keeps giving the same...

What does ** (double asterisk) mean in JavaScript?

javascript,syntax
I was reviewing a suggested edit for a JavaScript question and there were many changes suggested, but what caught my eye was the suggestion to change the following line: bodyCells[k].setAttribute("data-title", **array[i][m]**); To this: bodyCells[k].setAttribute("data-title", * * array[i][m] * * ); To me, both ** and * * don't look quite...

VHDL: (vcom-1136: std_logic_vector undefined)

syntax,vhdl
Getting a seemingly unexplainable syntax error saying that std_logic is undefined, even when it compiles earlier in the code! The first error occurs at the beginning of the entity, or line 37. I believe it has something to do with creating my own package but this is something I have...

Where does the syntax for expressions in SSRS come from?

reporting-services,syntax
The syntax for the expressions in SSRS seem to be very different to the other products that Microsoft produces. For example, I am not aware of any other tool that uses IIF() for an if statement and using 'is nothing' to assess if value is NULL. Is there any history...

Scheme several actions if an if-statement proves true

if-statement,syntax,scheme
The way I understand a scheme if-statement is that the first condition is when the if-statement is true, and the second statement is when it is false. What if I want several conditions for when the statement proves true? An example: (if (= a b) (set! ([a 2])) // This...

Why would “SELECT * FROM user” throw a syntax error? [duplicate]

c#,sql,database,ms-access,syntax
This question already has an answer here: SQL error: Incorrect syntax near the keyword 'User' 3 answers String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=CSTest.mdb"; String query = "SELECT * FROM user"; OleDbConnection connection = null; try { connection = new OleDbConnection(connectionString); connection.Open(); log("Database Connected!"); OleDbCommand test1 = new OleDbCommand(query, connection); OleDbDataReader...

What does the builtin function any() do?

python,if-statement,syntax,any
I did some google searching on how to check if a string has any elements of a list in it and I found this bit of code that works: if any(i in string for i in list): I know this works, but I don't really know why. Could you share...

What is the difference between _ and _variable in prolog?

syntax,prolog
I have encountered a lot of problems with a literal that starts with a _ such as _Peter. So what exactly would be the difference between: good(_,_). and good(_,_Peter). Thank you for answering my question!...

How to differentiate between assigning and declaring values from a function with multiple returns?

syntax,go
When retrieving multiple returns from a function, I get that you can declare variables for the values on the fly by using := or assign the values to already existing variables by simply using =. My issue occurs when I want to assign one of the return values to an...

Checking, if optional parameter is provided in Dart

syntax,dart,syntax-error,questionmark
I'm new to Dart and just learning the basics. The Dart-Homepage shows following: It turns out that Dart does indeed have a way to ask if an optional parameter was provided when the method was called. Just use the question mark parameter syntax. Here is an example: void alignDingleArm(num axis,...

Does the ternary operator work in constant definition?

objective-c,syntax,ternary
Why do I get a compiler error when using a ternary operator in the assignment of a CGSize const like this? CGSize const ksizeSmall = SOME_BOOLEAN_VARIABLE ? {187, 187} : {206, 206}; it does work like this... CGSize const ksizeSmall = {187, 187}; however, I want to add a boolean...

ORA-00939: too many arguments for function in CASE Statement

sql,oracle,syntax,arguments,substr
I'm getting the ORA-00939: too many arguments for function error from my case statement. I have tried splitting it up into multiple CASE statements but still get the same error. CASE WHEN l.fridge_door_modela_id = 'II-SH' THEN 'IW' WHEN l.fridge_door_modela_id = 'IIC-SH' THEN 'IW' WHEN l.fridge_door_modela_id = 'CD' THEN 'RPFX' WHEN...

Swift Function Syntax Breakdown

swift,syntax
I apologize in advance for the title of this question. I'm hoping to get a breakdown on some syntax elements of a function in Swift. The function: let call:NSURLSessionDataTask = session.dataTaskWithRequest(request) { data, response, error in if error != nil { println("error=\(error)") return } println("response = \(response)") } What I'm...

Java syntax with “ : ” [duplicate]

java,syntax
This question already has an answer here: Giving name to a loop 5 answers I've seen this character used in c# like an extends in Java, but recently I found this in a code loop: while (!stop) {} and also "pockets: "....it is followed by a for and inside...

Android SQLiteException syntax error code 1

android,syntax,android-sqlite
I made database in application, The code is giving error syntax (code 1) table exception. I read almost all questions about this exception, did all what it was said. but still it doesn't work. I couldn't find what the problem is. is there any one who can help me? My...

How to access javascript object without “name”

javascript,object,syntax
var text = '{ "employees" : [' + '{ "id": 999, "username": "Batman" } ]}'; obj = JSON.parse(text); var id = obj.employees[0].id; Question is, how to access as in example above id, from javascript object? In example above it has "name" to gain access to id, which is employees. But...

why there is a “SyntaxError: invalid syntax”

python,syntax
Error message: runfile('//rschfs1x/userrs/xd73_RS/Documents/Python Scripts/test_515.py', wdir='//rschfs1x/userrs/xd73_RS/Documents/Python Scripts') File "//rschfs1x/userrs/xd73_RS/Documents/Python Scripts/test_515.py", line 120 if __name__ == "__main__": ^ SyntaxError: invalid syntax Really not sure why thre is this problem def sendemail(alertmessage): msg = MIMEText(alertmessage) msg['Subject'] = 'Patent Data Error Message' msg['From'] = "[email protected]" msg['To'] = "[email protected]" # Credentials (if needed) username =...

Javascript for loop without recalculating array's length

javascript,arrays,loops,for-loop,syntax
In my Javascript reference book, for loops are optimized in the following way: for( var i = 0, len = keys.length; i < len; i + +) { BODY } Apparently, doing "len = keys.length" prevents the computer from recalculating keys.length each time it goes through the for loop. I...

Mysql Syntax “if length then” statement

mysql,sql,if-statement,syntax
I have a problem with syntax from mysql. i have my subselect: (SELECT uniqueid AS uniqueid_idx, calldate, src, dst, dstchannel, billsec, SUBSTR(CONVERT(IF(LENGTH(dst)>8,cdr.dst,CONCAT('67',cdr.dst)),UNSIGNED INTEGER),1,6) prefixo_normal FROM cdr) Can you see: "if you have cdr.dst > 8 then concat.." now i want verify: "if cdr.dst have <5 then create virtual column name...

Count variable Invalid Syntax [on hold]

python,variables,syntax
I'm back again with what you probably see as a stupid question. I have been working on a sim import random def main() game() def game(): suite_list() money = (100) count = (0) suite_list() card1 = random.randint(1,6) card2 = random.randint(1,6) card3 = random.randint(1,6) while user_money>start_bet: guess = int(input(""" Pick One!...

What is the difference between `a` and `*a` where `a` denotes a 2D array?

c,arrays,pointers,multidimensional-array,syntax
Pointers and arrays are closely associated with each other, so, if we have a 2-D array int a[3][4]={ 1,2,3,4, 5,6,7,8, 9,10,11,12}; Both printf("%p\n", a); and printf("%p\n", *a); print the same address. What I understand is maybe a is pointing to the base address of a while *a is pointing to...

Objective-C syntax: <>

objective-c,syntax
@interface A : B<C> @interface ViewController : UIViewController<MSBClientManagerDelegate> So I guess I get A is subclass of B, and B is superclass of A, but what's the relationship between B and C?...

Does Maria DB support ANSI-89 join syntax

sql,database,join,syntax,mariadb
Does Maria DB support ansi-89 join syntax? SELECT sites.site_id, sites.site_name, pages.page_id, pages.page_title FROM sites, pages WHERE sites.site_id = pages.site_id; or only ansi-92 syntax? SELECT sites.site_id, sites.site_name, pages.page_id, pages.page_title FROM sites INNER JOIN pages ON sites.site_id = pages.site_id; ...

Double dollar variables with arrays

php,syntax
I am trying to access the first item of an array using the double dollar syntax, but it doesn't work as I would want it to. <?php $a = 'test'; $test = ['a', 'b']; echo $$a[0]; This will say that the variable t is undefined, because it renders the $a[0]...

While statement has no body?

java,loops,syntax,while-loop
I have a number of statements in one procedure like this: while( x + ++flips < 8 && board[x + flips][y] == opponent ); The (standard "Oracle") compiler is returning the error: "While statement has no body." Is this required by the language specification, or is it compiler specific? Is...

changing letter into an encryption in java. simple call

java,syntax,ascii
What is the other way to change "a" to e.g."\n65" or other call in java which is based on ascii? this is not taught to java developers anymore but it was nice to know. i just forgot, but i need to use it for our project

Javascript For Loop with Iterator In the Middle and Decrement Operator to the Left of i?

javascript,for-loop,syntax,decrement
For a non-recursive example of a factorial function I found this example and am having a little difficulty tracing through the code: function fact(x) { if(x == 0) { return 1; } if(x < 0 ) { return undefined; } for(var i = x; --i; ) { x *= i;...

Adding selectmenu on select that's calling functions

javascript,jquery,jquery-ui,syntax,jquery-ui-selectmenu
I have a script that loads html content to a div and applies jquery tabs at the same time. However, I want to get JQuery Selectmenu on my select at the same time. I'm having trouble figuring out how to nest these. I'll be continuing looking at the API Docs,...

Java syntax to Groovy syntax

java,groovy,syntax
I am not really sure how to translate this to groovy syntax. Have checked this differences with java page already. Thanks! TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String...

Why do I get a “MySQLSyntaxErrorException:” error?

java,mysql,sql,syntax
Syntax error, I can't seem to find it. I'm new to databases. Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database ( ID INTEGER NOT NULL, QUESTION varchar(100) NOT NULL, ANSWER...

Python iterative loop

python,loops,syntax,iteration
I'm trying to iterate through a search list, I've written it like I would in C but I want to re-write this more pythonic. I've been trying with enumerate but I can't seem to get it to work, It is searching lines of data for key-words which are saved in...

How to jump/display the column of an error

python,vim,syntax,pylint,syntastic
To check the syntax of my python scripts I am using the syntastic vim plugin with pylint as checker. Is there a way to not only display or highlight the line where an error occurs but the column/exact position of this error too? I used a vim syntax checker plugin...

An irritating Issue about ruby hashes

ruby,hash,syntax
Why does ruby sometimes interpret a hash as being a block of code? For example I have a function called 'required' that takes a hash so I do: required { base_uri: String, endpoints: String, destination: String, credentials: Hash} and it think's it's a block of code and errors with unexpected...

Java syntax explanation - getMenuInflater()

java,android,syntax
Just downloaded android studio, and I am using big nerd ranch's guide to android programming to learn the ropes. When you start android studio this code is already in the main activity file: @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar...

Parenthesis after variable name C++

c++,syntax
Working with the below source code (it is open source) and I've never seen parenthesis after a variable name. UDefEnergyH is definitely a variable as can be seen in line 1. Can anyone tell me what these parenthesis are doing? Don't really know how to Google this. Thanks. bins[0] =...

Confused with the second variable of task : some_random_name1, [:some_random_name2] => :environment in rake?

ruby,syntax,rake
I am new to ruby and rake, and currently confused with some ruby syntax. task :some_random_name1, [:some_random_name2] => :environment do |task, args| end What does [:some_random_name2] here mean? I know some_random_name1 is a task that depends on another task :environment, and task and args in |task, args| are arguments from...

Simple ruby syntax if statement. Is this possible?

ruby,if-statement,syntax
I'm really new to programming and would like to know if this is possible: def lock(a,b,c,d) if (a == 3 || a == 5 || a == 7 && b == 2 && c == 5 || c == 6 && d == 8 || d == 9 || d...

Is this list comprehension pythonic enough? [duplicate]

python,syntax,list-comprehension
This question already has an answer here: Converting a loop with an assignment into a comprehension 2 answers Let's say I want to create a list of ints using Python that consists of the cubes of the numbers 1 through 10 only if the cube is evenly divisible by...

Python stats.linregress syntax error

python,syntax,regression,linear
I am trying to calculate the regression of the x and y variables, trace_no and twwt, respectively. The variable are 151 x 1 arrays. The code is outputting a syntax error: File "./seabed_dip_correction.py", line 32 slope, intercept, r_value, p_value, std_err, Syy/Sxx = stats.linregress(trace_no,twtt) SyntaxError: can't assign to operator I have...

Why does adding parentheses in if condition results in compile error?

syntax,go,syntax-error
The following Go code runs OK: package main import "fmt" func main() { if j := 9; j > 0 { fmt.Println(j) } } But after adding parentheses in condition: package main import "fmt" func main() { if (j := 9; j > 0) { fmt.Println(j) } } There is...

Symbolic notation for functions in Matlab

matlab,syntax,symbolic-math
Is there a way to use actual symbols (like the square root symbol instead of writing "sqrt()" and integral and sum/product signs instead of "integrate", "sum", etc.) as in Mathematica?

Why does pattern “*.so?(.*)” produce a syntax error in a script but not on command line?

bash,shell,syntax
The pattern is a little unusual because I added the trailing "?(.*)" portion. It works on command line as I expected but I get a syntax error for the same in a script. $ bash --version GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu) ... $ cat x.sh touch a.so a.so.1 ls *.so?(.*)...

How to DROP DATABASE named “/”

mysql,database,syntax,drop-database
There is this database created automatically with a CMS. the database name is "/" without quotes. and when trying do delete it, this shows up. mysql> DROP DATABASE /; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version...

How can I tell the dartanalyzer what kind of Element the selected object is?

object,syntax,types,dart
I have the code if(querySelector('#username').value!="") and it is working. But Darteditor warns me, that the getter 'value' is not defined for the class 'Element'. I know, that what the querySelector returns is an InputElement and therefore, my question is only for reasons of beauty and to remove the warnings. How...

MySQL - Querying for names for a different table corresponding to their ids

mysql,syntax
I need to get names of from and to users to display messages. I have two tables one user table CREATE TABLE IF NOT EXISTS USERS( USER_ID INT UNSIGNED NOT NULL, USER_EMAILID VARCHAR(100) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL, USER_FIRST_NAME VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL, USER_LAST_NAME...

Ruby on Rails favoriting controller & syntax problems

ruby-on-rails,ruby,syntax,favorites
I'm creating a "destroy" method in my favorites_controller. Not sure how I should express the commented-out requirement below, asking to find the current user's favorite with the ID in the params. I know I'm close but my current knowledge of ruby syntax is not up to par yet. An "undefined...

Javascript unusual FOR loop. Please, confirm that my interpretation is correct

javascript,syntax,minify
I have a piece of code in javascript: for ( m = a[1], s = a[2], c.hash_match = i.replace(m, ""), o.lastIndex = 0; a = o.exec(s); ) { e[a[1]] && (c[e[a[1]]] = c[e[a[1]]] || decodeURIComponent(a[2])); } And how i think is works: m = a[1]; s = a[2]; c.hash_match =...

Why is a defined token not recognized during syntax analysis in C using Bison?

c,syntax,compiler-construction,token,lexical
I'm currently working on a simple infix-to-postfix compiler for a given grammar. I'm currently at the stage of syntax analysis. I have already written a lexical analyzer, using Flex library, however I'm stuck on a seemingly simple problem. The information below might seem like a lot to process, but I...

How to access Objective C unnamed parameters of some method?

objective-c,methods,syntax,parameters
All I've found on the web about parameters of methods in Objective C is that they are optional, but if I don't label each input parameter of some method, how do I access them? Here's an example of what I'm trying to do: - (float) divNum1: (int) AndNum2: (int); then...

C structure syntax

c,syntax
C header sample. typedef LPVOID UKWD_USB_DEVICE; typedef struct _UKWD_USB_DEVICE_INFO { DWORD dwCount; unsigned char Bus; unsigned char Address; unsigned long SessionId; USB_DEVICE_DESCRIPTOR Descriptor; } UKWD_USB_DEVICE_INFO, *PUKWD_USB_DEVICE_INFO, * LPUKWD_USB_DEVICE_INFO; My Understanding struct defines a structure (the part between {}). The structure's type is _UKWD_USB_DEVICE_INFO. After the closing } UKWD_USB_DEVICE_INFO is an...

New python async and await keywords [closed]

python,asynchronous,syntax
Can someone explain the new syntax outlined in PEP 0492: Coroutines with async and await syntax? What will be the main differences between something like def do_nothing(): return and async def do_nothing(): return ...

Assigning a value to an object of type AnyObject

swift,syntax,parse.com
I have a variable var post :AnyObject? which is an object that I got back from a Parse API call. I want to do this post["caption"] = captionTextView.text but I get the following error message Cannot subscript a value of type 'AnyObject?' with an index of type 'String' I already...

EXPLAIN in postgresql not working

sql,postgresql,syntax,syntax-error,explain
I have the following SQL code but it's not working, it says syntax error: EXPLAIN DROP TABLE cool_table Does anyone know why? Edit: I wrote this because I was taught to always use EXPLAIN before running a query on the database to avoid running a task that's too much for...

gen_server handle_info/2 clarification

syntax,erlang,gen-server
While reading through Erlang and OTP in action, I ran across some weird syntax regarding records that I'm having trouble wrapping my head around. I'm hoping someone can clarify what's going on in the handle_info for timeouts here: handle_info({tcp, Socket, RawData}, State) -> do_rpc(Socket, RawData), RequestCount = State#state.request_count, {noreply, State#state{request_count...

Is this Swift syntax efficient?

ios,swift,syntax
Would this for loop fire each time the getter is accessed ? Or does Swift cache it 'behind the scenes' ? var colors: [UIColor] { get { var colors = [UIColor]() let palette = [UIColor.redColor(), UIColor.greenColor(), UIColor.blueColor(), UIColor.orangeColor(), UIColor.purpleColor(), UIColor.yellowColor()] var paletteIndex = 0 for _ in 0..<photos.count { colors.append(palette[paletteIndex])...

Why are brackets required to print type information of .?

haskell,syntax,parse-error
To print the type information of . I use : λ> :type (.) (.) :: (b -> c) -> (a -> b) -> a -> c If I omit the brackets , causes an error : λ> :type . <interactive>:1:1: parse error on input ‘.’ The same is not true...

Reading binary file to a string but the types are mixed

c,file-io,syntax,binaryfiles
I'm trying to read a binary file but when I read its characters it doesn't looks like it's formatted with char type so for example the numbers don't have their ASCII value instead, their actual value but letters does have ASCII value. Why is that? Also, when I create a...

SyntaxError: invalid syntax?

python,syntax
Good afternoon, I am developing a script in python and while I am trying to compile it from the terminator/terminal i always get this error, but I cannot understand where is the syntax error? File "_case1.py", line 128 print ('########################') ^ SyntaxError: invalid syntax Then I just change the position...

Java - Explicit method call for a generic class? [duplicate]

java,google-app-engine,generics,syntax
This question already has an answer here: Odd method call in java using a dot operator to access a generic list 5 answers I am following a free google appengine programming course at udacity (Developing Scalable Apps In java, a pretty good introductory course to appengine by the way)....

parenthetical parameters in Ruby / Rails

ruby-on-rails,ruby,methods,syntax,parameters
Learning Ruby / Rails, and encountered this with ERB templating: Works: <%= link_to image_tag(link.screenshot.url(:thumb)), link.screenshot.url(:original) %> Doesn't work: <%= link_to image_tag link.screenshot.url(:thumb), link.screenshot.url(:original) %> In the first one, the parameters for image_tag are in parentheses. For the other, they are not. I've come to understand in Ruby that methods don't...

What difference does variable order/side make with relational operators?

php,syntax,operators
Compare: if (donald_duck != null) if (roast_potatoes > 9000) if (love === 'explosions') and if (null != donald_duck) if (9000 <= roast_potatoes) if ('explosions' === love) In the languages I've written in, I've always used the first order since it makes sense human-wise. e.g. "Is the parrot dead?" vs "Is...

What does `\+` signify as an operator in prolog?

syntax,prolog
I have encountered the symbol \+ in prolog and am not sure as to what it signifies. I have gone through the prolog documentation and am either not being too resourceful or have not really noticed it. Thank you for your answer! ...

Python method that can be called on a list of objects

python,oop,syntax
When a method is called on an object in python as: obj.func() then python passes the obj as the first argument to the func(). I want to do something like: [obj1, obj2].func() and have it processed as: [obj1.func(), obj.func()] Is there a way of defining this kind of methods in...

Unable to recognize syntax error [closed]

perl,syntax
My code, taken almost out of the module cpan page: use strict; use warnings; use LWP::Curl; my $lwpcurl = LWP::Curl->new(); my $referer = 'http://www.example.com/'; my $post_url = 'https://example'; my $key='363073020844984X3v2'; my $hash='73wKwB802h8y26VrmyGD4TIqXSnsV7u39DDOOCd82578t9c92paeBABnMH0ahzp6lzH'; my $action='boot'; # ACTION="info&ipaddr=true&mem=true&hdd=true&bw=true" my $hash_form = { 'KEY' => $key, 'HASH' => $hash, 'action' => $action, }...

What is the correct way to create a object array in java? [duplicate]

java,syntax
This question already has an answer here: Difference between int[] array and int array[] 23 answers I've seen examples such as: Type arrayname[] = new Type[]; also as written as: Type[] arrayname = new Type[] I am quite confused about such expressions! Where exactly should I put the []?...

What is the use of text with colon operator (eg: Test:) in java [duplicate]

java,syntax
This question already has an answer here: “loop:” in Java code. What is this, why does it compile? 12 answers In one of the forum I found below code as a question: public class Test{ public static void main(String[] args){ System.out.println("Hello"); Test: System.out.println("World"); } } And asked what would...

What's this Coffescript use of then?

syntax,coffeescript,semantics
In Trevor Burnham's book on Coffeescript (p81) he has newcard.save().then => ... Which is not part of a conditional or a switch statement. Is then just a joining word for the syntax or does it have a semantic purpose?...

What does the following javascript syntax mean?

javascript,jquery,plugins,syntax
I'm currently learning to develop javascript/jquery plugins and I've noticed many of them have the following syntax: var pluginName = window.pluginName || {}; I'm having a hard time understanding what this means, specifically the OR curly braces part. If someone could shed light on what this means in the context...

C++ - Why does 2 local references to the same object stay in sync?

c++,pointers,syntax,reference,variable-assignment
I would like to understand what's going on here. Obviously, there's some aspect of references or assignment operators that I am not getting right. Objective: Within a function, I want to work with 2 local reference variables to various elements of the same list: one is the iterated over and...

Java For Loop Termination Condition: == vs <= vs >=

java,for-loop,syntax
for (int i = lowerBound; i == upperBound; i++) { //Code goes here } I want the last time the for loop is run to have i equaling upperBound. Is this the right syntax? If so why might one ever use <= or >=? Thanks in advance. :)...

php syntax error with if and else

php,syntax
I have the following markup.I am not able to make it work.It shows syntax error. if(has_terms( array('something','else'), 'product_cat' ) ) { $output .= '<div class="list_image">'; $output .= '</div>'; }else{ $output .= '<div class="list_post">'; $output .= '</div>'; } endif; What syntax error I made?...

The strange syntax of a C debug macro

c,syntax
Can anyone explain to me the C-syntax below (from this tutorial)? I understand this is a macro for C, but the "DEBUG %s:%d: " M "\n" part seems strange to me: why is there the macro parameter 'M' in the middle of the format part? #define debug(M, ...) fprintf(stderr, "DEBUG...

Yaml syntax to create this array

syntax,yaml
Given the following simple yaml data, foo: 1 bar: - one - two if I want to create an array of the exact same data structure, what's the correct way? I've tried first: foo: 1 bar: - one - two - three second: foo: 2 bar: - one1 - two2...

Bash script error server issue

linux,bash,syntax,scripting
I have the following bash script #!/bin/bash servers="server1.... server2...." seconds="3" # value for servers to differ (in seconds) now=$(date +%s) for server in $servers do ssh -l root ${server} "( date +%s )" > /tmp/.tmpdate echo "-" $(date +%s) >> /tmp/.tmpdate difference=$(awk -F '-' '{if ($1-$2 < 0) { print...

Why can I call the stream() method on objects of a class that don't have the stream()-method?

java,collections,syntax,java-stream
I'm a novice Java programmer at university. I discovered something today that broke one of my conceptions about how Java syntax works. public class testClass { ArrayList <String> persons = new ArrayList <String> (); public void run(){ Stream <String> personstream = persons.stream(); }} The method stream() is not found in...

map with class value segmentation fault

c++,class,memory,syntax
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. set(key, value) - Set or insert the...

PHP designer 8 Syntax Highlighing

php,syntax,designer,highlighting,phpdesigner
I tried to change the error highlighter in PHP Designer 8 in preferences but nothing changed. I want to change the annoying red background in error highlighter.

choose interface parameters in module declaration

syntax,system-verilog
Let's say I have a parameterized interface, e.g. interface Foo; parameter WIDTH=8; logic [WIDTH-1:0]data; endinterface Now I would like to use one of these interfaces with a width of (say) 16 in a module. How can I do this? I tried module foo(Foo #(.WIDTH(16)) in, output logic [15:0]out); assign out=in.data;...

Why is f <$> g <$> x equivalent to (f . g) <$> x although <$> is not right-associative?

haskell,syntax,infix-notation,applicative,infix-operator
Why is f <$> g <$> x equivalent to (f . g) <$> x although <$> is not right-associative? (This kind of equivalence is valid in a popular idiom with plain $, but currently $ is right-associative!) <*> has the same associativity and precedence as <$>, but behaves differently! Example:...

Regex - the difference in \\n and \n

php,regex,datetime,syntax,sscanf
Sorry to add another "Regex explanation" question to the internet but I must know the reason for this. I have ran this regex through RegexBuddy and Regex101.com with no help. I came across the following regex ("%4d%[^\\n]") while debugging a time parsing function. Every now and then I would receive...

UPDATED - calculating the tuition total

java,syntax,types,resolve
With help I got the program to run and answer the questions but it does not show the tuition total. Thanks for reading. Stackoverflow says I need to post more details so I am just typing for the details. import java.util.Scanner; public class Student { private static String FirstName; private...

Swift 2 - Pattern matching in “if”

swift,if-statement,syntax,pattern-matching,swift2
Recently I've saw the WWDC 2015 keynote from Apple. I also looked at some documentation but I can't find a "pattern matching in if" section, how it was written on one of the slides which they have shown. (73min 00sec video from Apple Events) Do you know what's this refers...

Erlang basic syntax error

syntax,erlang
I try to learn Erlang. I've installed a runtime but cannot get it working. The following code: X=3. works, but the following doesn't f(X)->X. or F() ->0. or F([])->[]. etc. all produce "1: syntax error before: '->'" I tried the "word_count" from this tutorial: http://www.ybrikman.com/writing/2012/11/04/seven-languages-in-seven-weeks-erlang/ and I get the same...

To generate a list for each map key as iterating through list?

groovy,syntax
I have a map and i need to insert a generated list to each map key in groovy as i am iterating through a list ! Code: def myMap = [:] anotherList.each{ object -> //here i do some work to get two elements def element1 = .. def element2 =...

Need help in understanding this c++ syntax [ const char * what () const throw () ]

c++,syntax
using namespace std; struct MyException : public exception { const char * what () const throw () // <--- This { return "C++ Exception"; } }; Please consider the marked line. Can sombody explain me the syntaxt used in that statement I think i should have narrowed down my query...

Show the data from two date fields ordered by the name of the month

mysql,syntax
I have two date fields. need to pull the data based on this two date fields and display it on monthly order (in words) like JAN , FEB... in MySQL. As of now my query is: SELECT `firstname` , `gender` , MONTH( `dol` ) AS 'month' FROM `student_details` WHERE `doa`...

How to define the type of elements in an rdf:Seq?

syntax,rdf,owl,rdfs,turtle
I want to create a property defining a rdf:Seq as a rdfs:range of an object : eg:myProperty a rdf:Property; rdfs:range rdf:Seq; . I'm looking for a way to define the type of the elements stored in the rdf:Seq. For example, I don't want this : eg:typeOfElement a rdf:Class; . eg:somethingElse...

What is correct syntax to use the php date function in a query

php,mysql,sql,date,syntax
So I have a problem, how do you use the php date function in a query in a php script. I want to convert the sql date from my database in the format Ymd. I don't want to change the format in my database but in my script. But I...

Looking for a nicer python syntax to pass multiple parameters to a single-parametered lambda

python,syntax,lambda
Let's take this code as an example (sort dict items by value): sorted(d.items(), key=lambda kv: kv[1]) The definition of key as a single-argument functor dictates this ugly lambda. Now, in this book I've seen some examples that use a much nicer syntax, like that: sorted(d.items(), key=lambda (k,v): v) But, unfortunately,...

How to specify the prior probability for scikit-learn's Naive Bayes

python,syntax,machine-learning,scikit-learn
I'm using the scikit-learn machine learning library (Python) for a machine learning project. One of the algorithms I'm using is the Gaussian Naive Bayes implementation. One of the attributes of the GaussianNB() function is the following: class_prior_ : array, shape (n_classes,) I want to alter the class prior manually since...

How can the suffix for numeric literals long int and long double both be l/L?

c++,syntax,literals
The suffix l and L for numeric literals long int and long double are the same. I don't understand how the compiler can know if I want my numeric literal to be a long int or a long double if they both share the same suffix. Why does this work?...

Ruby class instance variables in subclasses

ruby,oop,syntax,class-variables
Relying on this answer, I wrote the following class. When using it, I get an error: in 'serialize': undefined method '[]=' for nil:NilClass (NoMethodError). How can I access the variable @serializable_attrs in a base class? Base class: # Provides an attribute serialization interface to subclasses. class Serializable @serializable_attrs = {}...

PHP search with MySQL error [duplicate]

php,mysql,syntax
This question already has an answer here: PHP Parse/Syntax Errors; and How to solve them? 10 answers I tried to create a PHP search (searching in a MySQL DB). The Code should post the search results down below the form. So I wrote the following: <?php Session_Start(); $username=$_SESSION['username']; $password=$_SESSION['password'];...

Getting four bits from the right only in a byte using bit shift operations

c,syntax,bit-manipulation,bitwise-operators
I wanted to try to get only the four bits from the right in a byte by using only bit shift operations but it sometimes worked and sometimes not, but I don't understand why. Here's an example: unsigned char b = foo; //say foo is 1000 1010 unsigned char temp=0u;...

Is it possible to define a CAPL function returning a text string?

string,syntax,capl
I develop CAPL scripts in Vector CANoe, and I need to define several functions returning text strings. In C, I would write something like this: char * ErrorCodeToMsg(int code) or char [] ErrorCodeToMsg(int code) In CAPL, both definitions fail with a parse error. The only working solution I came up...

replace the $ in php variable declaration

php,syntax,bison,abstract-syntax-tree
I would like to extend the php syntax, in order to tell apart mutable and immutable variables. $a should be declared mutable (as in standard php) and #b should be declared immutable. I've read Hacking PHP syntax, and I couldn't figure out where can I define that variables declared with...

Can I merge an unknown named graph with an other in a SPARQL query?

syntax,merge,rdf,sparql
I want to query on two different named graphs as the default graph with SPARQL : SELECT * FROM <graph1> FROM <graph2> WHERE{ ... } My problem is that I don't know the URI of graph1, but I know a specific triple of graph1 allowing me to find his URI....