What does "=>" mean in import in scala? -


i new scala. looking through code , came code imports com.infinite.usermanagement.controllers.{ securityservice => basesecurityservice } package. wondering => sign means in import.

as others have mentioned, it's import rename. there 1 further feature proves astoundingly-useful on occasion highlight: if "rename" _, symbol no longer imported.

this useful in few cases. simplest you'd wildcard import 2 packages, there's name that's defined in both , you're interested in 1 of them:

import java.io.{ file=>_, _ } import somelibrary._ 

now when reference file, unambiguously use somelibrary.file without having fully-qualify it.

in case, have renamed java.io.file name out of way, not want name visible @ all. case packages contain implicits. if not want particular implicit conversion (e.g. if you'd rather have compile error) have delete name completely:

import somelibrary.{richfile => _, _} // files won't become surprise richfiles 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -