Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20556

Re: Find out if a variable is a Selection

Message-ID <2589620.ThK4HsqIrX@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-07-05 20:30 +0200
Subject Re: Find out if a variable is a Selection
Newsgroups comp.lang.javascript
References <b7bf07a2-3bf3-46a4-a792-a30e309a81de@googlegroups.com>

Show all headers | View raw


Lukas Bombach wrote:

> I'm writing a function to save and a function to load a selection. In the
> save function I simply return window.getSelection() . The load function is
> tricky. It takes all kinds of parameters. Inside the function I'm trying
> to figure out what has been passed and make a selection accordingly. That
> means I can pass it (10, 20) to make a selection from characters 10 to 20,
> some other stuff and last but not least I should be able to pass it a
> Selection object.
> […]
> Or is there another or even "right" way to do this?

The right way in languages as dynamic as these is either to use Duck Typing 
(feature tests).  Or not to overload parameters when you cannot reliably 
tell the types of possible arguments (apart) (such as with host objects); 
IOW, to provide *several* functions/methods with descriptive names for each 
such undetectable/indistinguishable type.

The right way includes not to top-post and not to use Google Groups for 
posting, at least until they have fixed the numerous bugs.

<http://jibbering.com/faq/>
<http://PointedEars.de/faq>
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Find out if a variable is a Selection Lukas Bombach <lukas.bombach@googlemail.com> - 2013-07-05 09:35 -0700
  Re: Find out if a variable is a Selection Lukas Bombach <lukas.bombach@googlemail.com> - 2013-07-05 09:38 -0700
  Re: Find out if a variable is a Selection Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-05 20:30 +0200

csiph-web