FAQ Database Discussion Community


Is there any reason I wouldn't use “let”?

javascript,const,var,ecmascript-6,let
Now that we can write ES6 and deploy it to browsers (using Traceur or 6to5 to support legacy user agents), is there any reason why we wouldn't use let or const as our default keywords for variable declaration? Is var dead? And if it is, can I configure my linting...

rspec undefined local variable that have been `let`

ruby,rspec,let
I need to test if a file contains a certain list of words. So I use let in a describe bloc : let (:test_rb_structure) { %w(nom, description, prix, rdv, validation, heure, creation) } And I call it like this in the same describe bloc : describe 'in app/controllers/api/v1/comptes.rb' do subject...

Understanding “let” expression in LISP

lisp,common-lisp,let
I am extremely new to lisp, had previous experience with functional programming (Haskell, SML). Why is this code returning 14, and not 10 (ie. 1 + 2y + 3 + 1)? (defvar x 1) (defun g (z) (+ x z)) (defun f (y) (+ (g 1) (let ((x (+ y...

Could this do-monad be replaced by a let block?

clojure,monads,let
The author here provides the following example usage of a do-monad to combine test generators: (require '[clojure.test.check.generators :as gen]) (require '[clojure.algo.monads :as m]) (m/defmonad gen-m [m-bind gen/bind m-result gen/return]) (def vector-and-elem (m/domonad gen-m [n (gen/choose 1 10) v (gen/vector gen/int n) e (gen/element v)] [v, e])) (gen/sample vector-and-elem) ([[0 -1...

Why does a macro that uses “let” expand differently from one that doesn't?

macros,lisp,common-lisp,let
I am new to Lisp and I am reading through Doug Hoyte's Let Over Lambda and he presents Paul Graham's nif macro in Chapter 3. I was playing around with that and made these two macros: (defmacro niffy (expr pos zero neg) `(cond ((plusp ,expr) ,pos) ((zerop ,expr) ,zero) (t...

OrientDB - LET variable in where

where,orient-db,let
I have a query very similar to this: SELECT FROM Post LET $category = (SELECT EXPAND(out('PartOf')) FROM $current), $poster = (SELECT EXPAND(in('Posted')) FROM $current) WHERE $poster <> #18:1 AND $poster IN (SELECT EXPAND(out('IsUser')) FROM (SELECT EXPAND(out('Related')) FROM #18:1) WHERE out('RelatedIn') IN ($category)) LIMIT 10000 And a graph like this: CREATE...

What does this Scheme code do?

scheme,let
Especially why we are using tailr and headr? I am not able to understand. (define (foo lst) (cond ((not (list? lst)) lst) ((null? lst) lst) (else (let* ((tail (cdr lst)) (head (car lst)) (tailr (foo tail)) (headr (foo head))) (append tailr (list headr)))))) ...

Block scope, function scope and local scope in Javascript

javascript,scope,var,let
Is block scope sometimes the same as function scope? I know function scope is for everything inside a function, but don't get what exactly a block scope is. For Javascript, is it currently recommended to use let / const instead of var for future maintenance? (This was from Airbnb...