Recent

Author Topic: When a public variable can not be assigned?  (Read 4012 times)

cpalx

  • Hero Member
  • *****
  • Posts: 753
When a public variable can not be assigned?
« on: July 22, 2010, 08:37:02 pm »
hello

my question is?

if i have a public variable in a class, when this variable is readonly ??

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1930
Re: When a public variable can not be assigned?
« Reply #1 on: July 22, 2010, 09:07:56 pm »
if you mean a field in the public section: afaik never.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: When a public variable can not be assigned?
« Reply #2 on: July 22, 2010, 11:08:33 pm »
hello

my question is?

if i have a public variable in a class, when this variable is readonly ??

A public variable by definition cannot be read only as far as I know. If you want a read only value, use constants instead. Constants cannot be changed & the compiler will throw an exception if you try to do so.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2615
Re: When a public variable can not be assigned?
« Reply #3 on: July 23, 2010, 12:58:23 am »
Or do you mean a readonly property ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018