Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function naming conflicts

What are some good patterns for development with packages that define the same function? In my case, lubridate and data.table both define wday.

like image 645
Sim Avatar asked Jul 15 '12 07:07

Sim


People also ask

What is naming conflicts?

A naming conflict occurs when you try to create or use an identifier that was previously defined. In some cases, naming conflicts generate errors such as Ambiguous name detected or Duplicate declaration in current scope.

Which is used to avoid naming conflicts?

Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.

What is naming conflicts in Java?

It helps Java to achieve abstraction. Naming Conflicts occur when a class implements two interfaces that have methods and variables with the same name.

Which is used to avoid naming conflicts in Java?

Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations.


1 Answers

You can use ::, it helps to specify which package to use:

lubridate::wday
function (x, label = FALSE, abbr = TRUE) 
UseMethod("wday")
<environment: namespace:lubridate>

data.table::wday
function (x) 
as.POSIXlt(x)$wday + 1L
<environment: namespace:data.table>
like image 50
Julius Vainora Avatar answered Sep 21 '22 12:09

Julius Vainora