| |
| Recipe 6.3: Transforming Objects into Different Types |
Last Updated: Sep 8, 2003
Status: Draft
|
|
|
|
How important is this problem to you?
(Login to Vote)
5.00 Rating, 1 Vote
|
|
How acceptable is the proposed solution?
(Login to Vote)
0.00 Rating, 0 Votes
|
|
Problem:
   
You want to convert an object into a different type. For example, you want to turn a simple string into a URI object.
Solution:
Use the transformation operators, from and as:
$uri = URI.new($my_string); # uses the default constructor
$uri = URI from $my_string; # uses the 'string' transformation
$uri = $my_string as URI; # same thing
Discussion:
|
|