Recent Additions - v1.0.9

Rui has been continuously evolving with new features and improvements. This section highlights the latest additions that make Rui more powerful and user-friendly than ever before.

New Features in v1.0.9

Type Checking Function

Added the type() function to get the type of any variable at runtime:

suppose str = "Hello"
suppose num = 42
suppose arr = [1, 2, 3]
suppose obj = {name: "Alice"}

write("String type: " + type(str))  // string
write("Number type: " + type(num))  // number
write("Array type: " + type(arr))   // array
write("Object type: " + type(obj))  // object

This function is particularly useful for debugging and creating dynamic programs that need to handle different data types.

Bug Fixes

Fixed several bugs reported by users:

  • Improved error handling for edge cases in array operations
  • Fixed memory leaks in long-running programs
  • Resolved issues with nested function calls
  • Enhanced string manipulation functions
  • Improved performance for large data structures

Previous Additions

Data Structures (Arrays & Objects)

Major enhancements to data structure support have been added:

Array Literals

Create arrays with the intuitive [1, 2, 3] syntax:

// Array literals with different data types
suppose numbers = [1, 2, 3, 4, 5]
suppose fruits = ["apple", "banana", "orange"]
suppose mixed = [1, "hello", true, 3.14]
suppose empty = []

write("Numbers: " + numbers)
write("Fruits: " + fruits)
write("Mixed: " + mixed)
write("Empty: " + empty)

Object Literals

Create objects with the {key: value} syntax:

// Object literals with various property types
suppose person = {
    name: "Alice",
    age: 25,
    isStudent: true,
    hobbies: ["reading", "coding"]
}

suppose config = {
    debug: true,
    maxRetries: 3,
    timeout: 5000
}

write("Person: " + person.name + ", Age: " + person.age)
write("Config: Debug=" + config.debug + ", MaxRetries=" + config.maxRetries)

Array Indexing

Enhanced array access with support for negative indexing:

suppose arr = [10, 20, 30, 40, 50]

// Positive indexing
write("First element: " + arr[0])   // 10
write("Second element: " + arr[1])  // 20
write("Third element: " + arr[2])   // 30

// Negative indexing
write("Last element: " + arr[-1])    // 50
write("Second to last: " + arr[-2])  // 40
write("Third to last: " + arr[-3])   // 30

// Safe access
if (length(arr) > 0) {
    write("First: " + arr[0] + ", Last: " + arr[-1])
}

Object Property Access

Access object properties with dot notation:

suppose company = {
    name: "TechCorp",
    founded: 2020,
    employees: 150,
    location: {
        city: "San Francisco",
        country: "USA"
    }
}

// Direct property access
write("Company: " + company.name)
write("Founded: " + company.founded)
write("Employees: " + company.employees)

// Nested property access
write("City: " + company.location.city)
write("Country: " + company.location.country)

// Modify properties
company.employees = 175
write("Updated employees: " + company.employees)