Hello,
no later than PHP5 my coder generation has to learned that some code are not state of the art. In my prottyping phase of my private project i have a good flashback to the good old days (i mean the 90's) and have testet some in-main-functions (so i call simple functions in the main.rs:)), now i want to put my quirky code into an better project organisation and my first try is my simple xml replacer function.
I have a simple raw string and in this raw string i want some replacing.
//main.rs
mod XML;
let XMLFile = (r#"Some {Tags] that i want to <h1>to {replace}</h1>"#);
let XMLFile = &XML::replaceTags(XMLFile.to_string(),"Tags".to_string(),"SomeWhat".to_string());
println!("{:?}", XMLFile);
//XML.rs
pub fn replaceTags(XMLFile:String,Tag:String,Text:String) -> String
{
XMLFile.replace (&Tag,&Text);
XMLFile
}
Now my Question is. How can is use a oop-getter and oop-setter functionality in mods? Are this possible, why i don't have a class with class variables and methods. Yes this functioned very well but i want an oop design pattern structure.
I want an XML::set function for setting the XMLFile String, an get function for getting back the modified XMLFile and the replace function for replace in an XMLFile Var that was previously set by that function.
Hmm i remember me that variables only can bet set in functions so my idea nesting an Function-Mod in the XML-Mod and setting an Module-Variable like an Object/Class-Variables cannot be functioned.
How can i simple create something like Classes in other oop-langs? Something is at the moment blocked in me, when i see no ConfFile = new XMFile, CoolFile = new XMLFile. Before i code an quirky framework i ask here:).
My first time i extend my Prototyping (thats functioned very well but is quirky:)):).