On 1/11/19 6:23 PM, Tom Browder wrote:
On Fri, Jan 11, 2019 at 20:15 ToddAndMargo via perl6-users <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
...
 > $p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry",
> AccountNo => 1234 } ); my Str $y = %Vendors{$x}<ContactName>.Str; say $y;'

In my experience, it helps often to avoid using strict typing unless really needed.

Best regards,

-Tom

There are instances where I get myself in a mess if I do not
type things.  So some I do and some I don't.  Keeps me out
of trouble.  Most times now I do.

One instance where I fly back and forth between strings and
integers is where I am checking revisions.  Is "12.3.4.1"
newer than "111.3.4.1"?  I do a split on the variable
at the dots, turn the string fragments into integers
and test each position one at a time.  The code was a
nightmare until I started using typing.  That found all
my mistakes with alacrity.  Code came out real elegant
after that.  I was pleased with my ingenuity.

I use .Str and .Int a lot now-a-days too.  Even if not
necessary, it is for maintainability when there is a conversion
going on that I have forgotten about.

In the question I posted the value had to absolutely be a Str
and nothing else.  If anyone added to it and was not
properly turning other things into a string, I wanted it
to instantly fail.

The Str in question was a HTML that was passing
a parts order to Thunderbird to mail to my vendors.

Reply via email to