Skip to content

Instantly share code, notes, and snippets.

@christoffer
Created September 9, 2013 20:47
Show Gist options
  • Save christoffer/6501288 to your computer and use it in GitHub Desktop.
Save christoffer/6501288 to your computer and use it in GitHub Desktop.
Missing symbols from ruby.
package com.my.package;
static import com.my.package.Symbols.*;
class MyClass {
// Symbol constants
enum Symbols { EXTRA_SOME_KEY }
void unpackExtras() {
Bundle extras = getIntent().getExtras();
// Explicit, three step rocket
extras.getString(Symbols.EXTRA_SOME_KEY.name());
// Using the statically imported enum
extras.getString(EXTRA_SOME_KEY.name());
}
}
@christoffer
Copy link
Author

It's a bit nasty for external usage though.

put(MyClass.Symbols.EXTRA_SOME_KEY.name(), "value");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment