- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Fwd: Re: types of strings
Sun, 2011-12-18, 16:29
exactly what i was looking for. :)
-------- Original-Nachricht -------- Betreff: Re: [scala-user] types of strings Datum: Sun, 18 Dec 2011 20:22:14 +0530 Von: missingfaktor
An:
HamsterofDeath
http://etorreborre.blogspot.com/2011/11/practical-uses-for-unboxed-tagged-types.html
On Sun, Dec 18, 2011 at 8:06 PM, HamsterofDeath <h-star [at] gmx [dot] de" rel="nofollow">h-star@gmx.de> wrote:
--
Cheers, missingfaktor.
-------- Original-Nachricht -------- Betreff: Re: [scala-user] types of strings Datum: Sun, 18 Dec 2011 20:22:14 +0530 Von: missingfaktor
http://etorreborre.blogspot.com/2011/11/practical-uses-for-unboxed-tagged-types.html
On Sun, Dec 18, 2011 at 8:06 PM, HamsterofDeath <h-star [at] gmx [dot] de" rel="nofollow">h-star@gmx.de> wrote:
hi,
i regularly encounter situations where strings are used. for example it
might be an url. or a resource key. or a string that is supposed to be
sent to a brower and has to be escaped.
and i regularly see errors caused by the fact that you cannot ask a
string if it has already been resolved (if it's a resource key) or
escaped, or if it is a relative or absolute url. if it even is one.
in java, i try to make this a bit safer by creating simple wrappers like
"class ResourceKey(val key:String)" to make sure i don't accidently mix
them up. is there a way to achieve this in scala without wrapper
classes? can i somehow (mis)use abstract types for this?
basically i want to say :
type AbsoluteUrl = ???
def iAmAbsolutelySureThisIsAnAbsoluteUrl(url:String) =
url.asInstanceOf[AbsoluteUrl]
--
Cheers, missingfaktor.