What are the double colons (::) in R?

As you probably have looked up the help page by now usage of :: helps to access the exact function from that specific package. When you load dplyr you probably got a message as follows.. So, for instance, if you would like to use intersect function from dplyr or base package, you need to specify using the :: double colons. Usage will be … Read more

Dynamic and static Scoping program differences

Static scoping means that x refers to the x declared innermost scope of declaration that has one. Since h is declared inside the global scope, the innermost x is the one in the global scope(it has no access to the xs in f and g, since it was not declared inside them), so the program prints 14 twice. Dynamic scoping means that x refers to the x declared in the most recent frame of the call-stack the … Read more

How do I pass the this context to a function?

Javascripts .call() and .apply() methods allow you to set the context for a function. Now you can call: Which would alert FOO. The other way around, passing obj_b would alert BAR!!. The difference between .call() and .apply() is that .call() takes a comma separated list if you’re passing arguments to your function and .apply() needs … Read more

class not declared in scope – even though .h was included

The common circular include problem occurs with:a.h b.h If some cpp includes “a.h” you might get away with it (if b.h didn’t really need a.h). But if that cpp instead includes b.h then b.h includes a.h BEFORE declaring things needed by a.h. Then a.h tries to include b.h but the include guard blocks that, so the compiler … Read more

Error: ‘else’ without ‘if’

Remove the semicolon at the end of this line: And please, please use curly brackets! Java is not like Python, where indenting the code creates a new block scope. Better to play it safe and always use curly brackets – at least until you get some more experience with the language and understand exactly when you can omit them.