syntax-error

NodeJS script with async/await causing syntax error (v7.10.0)

女生的网名这么多〃 提交于 2019-11-28 11:57:24
I am trying to use async/await in NodeJS but my script is throwing a syntax error. I was under the impression that async/await is supported naively since Node 7.6 . When I run node -v I get v7.10.0 . Here is the contents of index.js : async function getValueAsync() { return new Promise(function(resolve) { resolve('foo'); }); } let value = await getValueAsync(); console.log(value); But when I invoke this script with node index.js I get: let value = await getValueAsync(); ^^^^^^^^^^^^^ SyntaxError: Unexpected identifier at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at

PHP, Parse error: syntax error, unexpected T_FUNCTION [duplicate]

心不动则不痛 提交于 2019-11-28 11:29:33
问题 This question already has answers here : PHP anonymous function causes syntax error on some installations (3 answers) Closed 6 years ago . class test { public $do; function __construct($data="") { $this->parse($data); } private function parse($data) { // Decoding the functions $decoded_data = json_decode($data,true); array_walk_recursive($decoded_data,function(&$function) { $first_line = strtok($function, "\n"); preg_match("/\/\*#(.*?)\#*\//",$first_line,$matches); $function = create_function

Hash syntax in Ruby [duplicate]

假装没事ソ 提交于 2019-11-28 10:44:18
This question already has an answer here: Is there any difference between the `:key => “value”` and `key: “value”` hash notations? 5 answers According to The Well Grounded Rubyist : Ruby allows a special form of symbol representation in the hash-key position, with the colon after the symbol instead of before it and the hash separator arrow removed. In other words, this: hash = { :name => "David", :age => 49 } can also be written like this: hash = { name: David, age: 49 } I have tried the preceding code in ruby 1.8.7 and 1.9.2 - It is not working. What am I doing wrong? The new hash syntax in

Uncaught SyntaxError: Unexpected token ILLEGAL [duplicate]

爷,独闯天下 提交于 2019-11-28 09:40:10
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Unexpected token ILLEGAL in webkit I wrote a simple script for a hover over effect here http://jsfiddle.net/paDmg/368/ for this site http://avuedesigns.com/new/ - It works on jsfiddle, but I am getting Uncaught SyntaxError: Unexpected token ILLEGAL in my JavaScript when I put it live. It's on line 29 it is telling me which is the closing marks });​ $('#hover-grid .indiv-cell').hover(function() { //set variables

cannot find an initializer for type 'String' that accepts an argument list of type '(format: String, argument: UInt32

北慕城南 提交于 2019-11-28 09:03:02
问题 I created a playground in Xcode 6.3 (6D570) and input these following code: import UIKit var randum_num = arc4random_uniform(13) + 1 String(format: "card%i", arguments: randum_num) And I got this error: cannot find an initializer for type 'String' that accepts an argument list of type '(format: String, argument: UInt32 Sorry I'm complete new in Swift, thanks for any advices! P.S. I'm following this tutorial: link 回答1: You just have to omit "arguments:". Try like this: let randum_num =

Visual studio showing syntax errors in razor statements but works

两盒软妹~` 提交于 2019-11-28 08:19:50
问题 I've a project in MVC 3. It works perfectly and each time I build it, it succeeds. However, Visual Studio insist in showing compile errors in views in each razor syntax. For example: The name 'model' does not exist in the current context D:\ ... Detail.cshtml That line is simple: @model Namespace.DetailViewModel I've already tried: Cleaning solution Cleaning solution and deleting bin and obj folders. Closing VS and reopening it (even with a reboot in the middle). Note: I'm using Visual Studio

“non-static variable this cannot be referenced from a static context”?

≯℡__Kan透↙ 提交于 2019-11-28 08:10:07
问题 I'm a Java newbie and I'm trying to deploy a fibonacci trail through recursive function and then calculate the run time. here is the code I have managed to write: class nanoTime{ int fib(int n){ if(n==0) return 0; if(n==1) return 1; return this.fib(n-1)+this.fib(n-2); } public static void main(String[] args){ double beginTime,endTime,runTime; int n=10; beginTime = System.nanoTime(); n = this.fib(n); endTime = System.nanoTime(); runTime = endTime-beginTime; System.out.println("Run Time:" +

Visual Studio doesn't allow me to use certain variable names

不打扰是莪最后的温柔 提交于 2019-11-28 07:49:15
问题 I'm using Visual Studio 2010 Express. When I use certain variable names, like "near, "far", "IN", "OUT", I can't compile: I get syntax errors located after the variable name used. Example: z = 1.0/(far - near); Error: error C2059: syntax error : ')' How can I disable this "feature"? 回答1: far and near were built-in compiler keywords back in the 16-bit days. They no longer exist and they no longer have any meaning, but they're still defined as macros in the Windows headers for backwards

unexpected T_FUNCTION error when using “function (array $matches)”

廉价感情. 提交于 2019-11-28 07:42:38
问题 Hi I'm using the following code but I'm getting an "unexpected T_FUNCTION" syntax error for the second line. Any suggestions? preg_replace_callback("/\\[LINK\=(.*?)\\\](.*?)\\[\/LINK\\]/is", function (array $matches) { if (filter_var($matches[1], FILTER_VALIDATE_URL)) return '<a href="'. htmlspecialchars($matches[1], ENT_QUOTES). '" target="_blank">'. htmlspecialchars($matches[2])."</a>"; else return "INVALID MARKUP"; }, $text); 回答1: That happens when your PHP is older than 5.3. Anonymous

Function literal with multiple implicit arguments

試著忘記壹切 提交于 2019-11-28 07:22:32
问题 How to define function literal with multiple implicit arguments in Scala? I've tried this way: def create = authAction { (implicit request, user) ⇒ // Syntax error Ok(html.user.create(registrationForm)) } but it throws compilation error. 回答1: As stated in previous answer, you can only define a single implicit parameter for a function literal, but there is workaround. Instead of multiple implicit arguments you can write function literal as taking multiple argument lists with one argument each.