From 4e14517dfb51ae70584ee09c8948f9fcea95af6f Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Tue, 17 Jul 2018 09:39:17 +0200 Subject: [PATCH] Update page 'P# 1.0 Draft Specification' --- P%23-1.0-Draft-Specification.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/P%23-1.0-Draft-Specification.md b/P%23-1.0-Draft-Specification.md index a665538..aa03549 100644 --- a/P%23-1.0-Draft-Specification.md +++ b/P%23-1.0-Draft-Specification.md @@ -223,6 +223,20 @@ Above example will create a multi-dimensional associative array containing integ [8] => int(0), } +### 5.13. Type Casting +Type casting in P# works much as it does in C/C++ - the name of the desired type is written in parentheses before the variable which is to be cast: + * (bool) - casts to Boolean + * (float) casts to Float + * (int) - casts to Integer + * (object) - casts to Object + * (string) - casts to String + * (unset) - casts to NULL + + <% + string $str = "45"; + int $integer = 7 + (int) $str; // contains value: 52 + %> + ## Future P# Versions This paragraph describes an ideas for future versions of P# language specification * Pointers support