Skip to content

Instantly share code, notes, and snippets.

@serdarsen
Created May 25, 2019 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serdarsen/24272909595ac73b8ce47d1abf1cbf56 to your computer and use it in GitHub Desktop.
Save serdarsen/24272909595ac73b8ce47d1abf1cbf56 to your computer and use it in GitHub Desktop.
Double to string sample of vala : Calling a string property that contains "DoubleToString" result from base class
// The code below can be run and test in https://tio.run/#vala
public class Vehicle
{
public double Speed {get; set;}
public string SpeedText
{
owned get{return DoubleToString(Speed, "%.0f");}
}
public Vehicle()
{
}
protected string DoubleToString(double num, string format)
{
char[] buf = new char[double.DTOSTR_BUF_SIZE];
var str = num.format(buf, format);
return str;
}
}
public class Car : Vehicle
{
public Car()
{
}
}
public static int main(string[] args)
{
var car = new Car();
car.Speed = 1;
stdout.printf(car.SpeedText);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment