This entry was posted
on sobota, Lipiec 3rd, 2010 at 12:39 and is filed under Dla programistów.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Ten filmik zawiera lekko nieświeże informacje (Ruby 1.9 ma już lepsze wsparcie dla unikodu od Pythona). Zawiera także błędy w kodzie! Poprawny kod Pythona powinien być taki:
class Coord(object):
def __init__(self, lat=0.0, lon=0.0):
self.__lat, self.__lon = lat, lon
def getLat(self):
return self.__lat
def setLat(self, value):
if not -90.0 <= value 90.0 || value < -90.0)
throw new Exception("Bad latitude")
this._lat = value
}
}
Ten filmik zawiera lekko nieświeże informacje (Ruby 1.9 ma już lepsze wsparcie dla unikodu od Pythona). Zawiera także błędy w kodzie! Poprawny kod Pythona powinien być taki:
class Coord(object):
def __init__(self, lat=0.0, lon=0.0):
self.__lat, self.__lon = lat, lon
def getLat(self):
return self.__lat
def setLat(self, value):
if not -90.0 <= value 90.0 || value < -90.0)
throw new Exception("Bad latitude")
this._lat = value
}
}
Także pythonową definicję
class Coord(object):
def __init__(self, lat=0.0, lon=0.0):
self.lat, sel.lon = 0.0, 0.0.
w Scali można zapisać jeszcze krócej, bo w jednej linijce:
class Coord(var lat:Double = 0.0, var lon:Double = 0.0)
Jakiś gówniany soft w tym blogu, bo wcina spacje. Wkleiłem to też tu: http://gist.github.com/462994