Skip to content

Instantly share code, notes, and snippets.

@chemikadze
Last active December 14, 2015 04:49
Show Gist options
  • Save chemikadze/5031170 to your computer and use it in GitHub Desktop.
Save chemikadze/5031170 to your computer and use it in GitHub Desktop.
What is the difference between `var x = null` and `var x = _`?
package initializing
class WithNull { var x: Any = null }
class WithUnderscore { var x: Any = _ }
class PageObject(driver: WebDriver) {
WebDriverFactory.initElementsWithAjaxSupport(this,driver)
}
class FooPage(driver:WebDriver) extends PageObject(driver) {
@FindBy(name="bar")
private var barButton:WebElement = null // this is what all about
}
public initializing.WithNull();
Code:
0: aload_0
1: invokespecial #19; //Method java/lang/Object."<init>":()V
4: aload_0
5: aconst_null
6: pop
7: aconst_null
8: putfield #11; //Field x:Ljava/lang/Object;
11: return
}
public initializing.WithUnderscore();
Code:
0: aload_0
1: invokespecial #19; //Method java/lang/Object."<init>":()V
4: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment