From f9b7baa5463569be9c39ac2591bd31939f358a6d Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sat, 2 Jul 2016 15:54:37 +0200 Subject: [PATCH] Prettier str() for arrays (cherry picked from commit 38ed5d9c7d5b3ce03e7ac5141ef0115a605e75bf) --- core/variant.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/variant.cpp b/core/variant.cpp index caa9b998de2..0d97032f434 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1559,72 +1559,78 @@ Variant::operator String() const { case VECTOR2_ARRAY: { DVector vec = operator DVector(); - String str; + String str("["); for(int i=0;i0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case VECTOR3_ARRAY: { DVector vec = operator DVector(); - String str; + String str("["); for(int i=0;i0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case STRING_ARRAY: { DVector vec = operator DVector(); - String str; + String str("["); for(int i=0;i0) str+=", "; str=str+vec[i]; } + str += "]"; return str; } break; case INT_ARRAY: { DVector vec = operator DVector(); - String str; + String str("["); for(int i=0;i0) str+=", "; str=str+itos(vec[i]); } + str += "]"; return str; } break; case REAL_ARRAY: { DVector vec = operator DVector(); - String str; + String str("["); for(int i=0;i0) str+=", "; str=str+rtos(vec[i]); } + str += "]"; return str; } break; case ARRAY: { Array arr = operator Array(); - String str; + String str("["); for (int i=0; i