Title: Change Data Type
Slug: change_data_type
Summary: Change Data Type Using Scala.
Date: 2017-01-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon
This tutorial was inspired by the awesome Scala Cookbook.
In [1]:
// Convert a float to an integer
32.34.toInt
Out[1]:
In [2]:
// Convert a string to an integer
"23394".toInt
Out[2]:
In [3]:
// Convert a string to a double
"23394".toDouble
Out[3]:
In [4]:
// Convert a string to float
"23394".toFloat
Out[4]:
In [5]:
// Convert an integer to float
3923.toFloat
Out[5]:
In [6]:
// Convert a string to long
"23394".toLong
Out[6]:
In [7]:
// Convert a string to short
"23394".toShort
Out[7]:
In [10]:
// Convert a string to byte
"10".toByte
Out[10]:
In [9]:
// Convert an integer to string
2393.toString
Out[9]: