Normal arguments vs. keyword arguments
How are “keyword arguments” different from regular arguments? Can’t all arguments be passed as name=value instead of using positional syntax? 10 Answers 10
How are “keyword arguments” different from regular arguments? Can’t all arguments be passed as name=value instead of using positional syntax? 10 Answers 10
I was making my way through the Scala playframework tutorial and I came across this snippet of code which had me puzzled: def newTask = Action { implicit request => taskForm.bindFromRequest.fold( errors => BadRequest(views.html.index(Task.all(), errors)), label => { Task.create(label) Redirect(routes.Application.tasks()) } ) } So I decided to investigate and came across this post. I still … Read more
I’ve been using C++ for a short while, and I’ve been wondering about the new keyword. Simply, should I be using it, or not? With the new keyword… MyClass* myClass = new MyClass(); myClass->MyField = “Hello world!”; Without the new keyword… MyClass myClass; myClass.MyField = “Hello world!”; From an implementation perspective, they don’t seem that … Read more
What is the difference between const and final keyword in Dart? 15 Answers 15
I’d like to call a function in python using a dictionary. Here is some code: d = dict(param=’test’) def f(param): print(param) f(d) This prints {‘param’: ‘test’} but I’d like it to just print test. I’d like it to work similarly for more parameters: d = dict(p1=1, p2=2) def f2(p1, p2): print(p1, p2) f2(d) Is this … Read more
This is probably a very trivial question, but I haven’t been able to find the answer neither through web search engines, nor on php.net. Please just direct me to where I can read about this, if you haven’t got time to explain. What does the ‘var’ keyword mean in PHP? Are there any differences between … Read more
While playing this puzzle (It’s a Java keyword trivia game), I came across the native keyword. What is the native keyword in Java used for? 10 s 10 Minimal runnable example Main.java public class Main { public native int square(int i); public static void main(String[] args) { System.loadLibrary(“Main”); System.out.println(new Main().square(2)); } } Main.c #include <jni.h> … Read more
A while ago I came across some code that marked a member variable of a class with the mutable keyword. As far as I can see it simply allows you to modify a variable in a const method: class Foo { private: mutable bool done_; public: void doSomething() const { …; done_ = true; } … Read more
For templates I have seen both declarations: template < typename T > template < class T > What’s the difference? And what exactly do those keywords mean in the following example (taken from the German Wikipedia article about templates)? template < template < typename, typename > class Container, typename Type > class Example { Container< … Read more
In C and many other languages, there is a continue keyword that, when used inside of a loop, jumps to the next iteration of the loop. Is there any equivalent of this continue keyword in Ruby? 7 s 7 Yes, it’s called next. for i in 0..5 if i < 2 next end puts “Value … Read more