functions.sol 577 B

1234567891011121314151617181920212223
  1. // get_initial_bound is called from the constructor
  2. function get_initial_bound() returns (uint256 value) {
  3. value = 102;
  4. }
  5. contract foo {
  6. uint256 bound = get_initial_bound();
  7. /** set bound for get with bound */
  8. function set_bound(uint256 _bound) public {
  9. bound = _bound;
  10. }
  11. // Clamp a value within a bound.
  12. // The bound can be set with set_bound().
  13. function get_with_bound(uint256 value) public view returns (uint256) {
  14. if (value < bound) {
  15. return value;
  16. } else {
  17. return bound;
  18. }
  19. }
  20. }