Why Is `Export Default Const` invalid?

const is like let, it is a LexicalDeclaration (VariableStatement, Declaration) used to define an identifier in your block. You are trying to mix this with the default keyword, which expects a HoistableDeclaration, ClassDeclaration or AssignmentExpression to follow it. Therefore it is a SyntaxError. If you want to const something you need to provide the identifier … Read more

Android Preferences: How to load the default values when the user hasn’t used the preferences-screen?

this question is similar to mine: initialize-preferences-from-xml-in-main-activity Just use this code in onCreate method: PreferenceManager.setDefaultValues(this, R.xml.preference, false); It will load your preferences from XML, and last parameter (readAgain) will guarantee that user preferences won’t be overwritten. That means setting the readAgain argument to false means this will only set the default values if this method … Read more

Why does the Scala compiler disallow overloaded methods with default arguments?

I’d like to cite Lukas Rytz (from here): The reason is that we wanted a deterministic naming-scheme for the generated methods which return default arguments. If you write def f(a: Int = 1) the compiler generates def f$default$1 = 1 If you have two overloads with defaults on the same parameter position, we would need … Read more

Changing default port (i.e. 5037) on which adb server runs

Use the environment variable ANDROID_ADB_SERVER_PORT to select the port. The following works under bash: $ export ANDROID_ADB_SERVER_PORT=12345 $ adb start-server * daemon not running. starting it now on port 12345 * * daemon started successfully * $ adb devices List of devices attached TA2070M5O6 device $ ANDROID_ADB_SERVER_PORT=6789 adb devices * daemon not running. starting it … Read more

python’s webbrowser launches IE, instead of default browser, on Windows relative path

My main issue was a bad URL by attempting prepend file:// to a relative path. It can be fixed with this: webbrowser.open(‘file://’ + os.path.realpath(filename)) Using webbrowser.open will try multiple methods until one “succeeds”, which is a loose definition. The WindowsDefault class calls os.startfile() which fails and returns False. I can verify that by entering the … Read more

What is an iterator’s default value?

By convention a “NULL iterator” for containers, which is used to indicate no result, compares equal to the result of container.end(). std::vector<X>::iterator iter = std::find(my_vec.begin(), my_vec.end(), x); if (iter == my_vec.end()) { //no result found; iter points to “nothing” } However, since a default-constructed container iterator is not associated with any particular container, there is … Read more

Is there a reasonable approach to “default” type parameters in C# Generics?

Subclassing is the best option. I would subclass your main generic class: class BaseGeneric<T,U> with a specific class class MyGeneric<T> : BaseGeneric<T, string> This makes it easy to keep your logic in one place (the base class), but also easy to provide both usage options. Depending on the class, there is probably very little extra … Read more