Dave Hayes writes:
>
> if (ref($text) eq 'Gtk2::Entry') {
I expect isa() is friendlier to subclasses, though wouldn't matter
within a self-contained spot of code as such.
A bit of a grep shows eq instead of isa in a few modules in cpan. I see
with some embarrassment one of mine too! :-) Mayb
Pelle Nilsson writes:
> if (substr($text, 0, 11) eq 'Gtk2::Entry') {
> print "Entry!\n";
> } elsif (substr($text, 0, 14) eq 'Gtk2::ComboBox') {
> print "ComboBox!\n";
> }
This might be better written as
if (ref($text) eq 'Gtk2::Entry') {
...
:)
--
Dave Hayes - Consultant - Altad
* Pelle Nilsson [2010-04-16 13:00]:
> If an object is used in a string context it will return
> something like
>
> Gtk2::Entry=HASH(0x12cfba8)
>
> so you can use something like
>
> if (substr($text, 0, 11) eq 'Gtk2::Entry') {
> print "Entry!\n";
> } elsif (substr($text, 0, 14) eq 'Gtk2::ComboB
On Fri, 2010-04-16 at 12:59 +0200, Pelle Nilsson wrote:
> If an object is used in a string context it will return something like
>
> Gtk2::Entry=HASH(0x12cfba8)
>
> so you can use something like
>
> if (substr($text, 0, 11) eq 'Gtk2::Entry') {
> print "Entry!\n";
> } elsif (substr($text, 0,
On Fri, 2010-04-16 at 09:25 +, l...@guenther-sohler.net wrote:
> Its really a stupid question.
this is not good OOP.
if you feel the need to do a type check then you're probably doing the
wrong thing.
> If I write
>
> $text=Gtk2::Entry->new;
> or
> $text=Gtk2::ComboBoxEntry->new;
>
> how c
If an object is used in a string context it will return something like
Gtk2::Entry=HASH(0x12cfba8)
so you can use something like
if (substr($text, 0, 11) eq 'Gtk2::Entry') {
print "Entry!\n";
} elsif (substr($text, 0, 14) eq 'Gtk2::ComboBox') {
print "ComboBox!\n";
}
/Pelle
(sorry fo
Its really a stupid question.
If I write
$text=Gtk2::Entry->new;
or
$text=Gtk2::ComboBoxEntry->new;
how can I check later in the program if $text is an Entry or an
ComboBoxEntry ?
if($text->get_text != undef)
{
}
does not help. It already tries to call an undefined function
rds
___