Redeclaration of parameters
Posted
by
Scott
on Stack Overflow
See other posts from Stack Overflow
or by Scott
Published on 2012-06-11T16:08:57Z
Indexed on
2012/06/11
16:40 UTC
Read the original article
Hit count: 207
While looking through the Selenium source code I noticed the following in the PageFactory:
public static <T> T initElements(WebDriver driver, Class<T> pageClassToProxy) {
T page = instantiatePage(driver, pageClassToProxy);
initElements(driver, page);
return page;
}
public static void initElements(WebDriver driver, Object page) {
final WebDriver driverRef = driver;
initElements(new DefaultElementLocatorFactory(driverRef), page);
}
What is the benefit of having the following line?
final WebDriver driverRef = driver;
Wouldn't it have made sense to just make the parameter final, and then passing that along to the next method without declaring the new reference?
© Stack Overflow or respective owner