Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Hash Arrays (https://forums.graalonline.com/forums/showthread.php?t=134257204)

fowlplay4 12-05-2009 08:26 AM

Hash Arrays
 
Well I've recently found a liking to Ruby and it's hash arrays. It would be really rad if we had them in GS2. Hash rockets ftw.

Theory usage:

PHP Code:

function onCreated() {
  
temp.noises = {
    
"cat" => "meow",
    
"dog" => "woof",
    
"manbearpig" => "rawr",
    
"algore" => "im super serial guise"
  
};
  
temp.data = {
    :
ip => "127.0.0.1",
    :
port => 8080
  
};
  echo(
temp.noises["cat"]); // would echo "meow"
  
echo(temp.data[:ip]); // would echo "127.0.0.1"



Tigairius 12-05-2009 08:35 AM

Wow, that's pretty awesome. I support this suggestion.

Twinny 12-05-2009 08:52 AM

Given how long we've requested associative arrays for.... >_<

Crow 12-05-2009 01:08 PM

Quote:

Originally Posted by Twinny (Post 1542626)
Given how long we've requested associative arrays for.... >_<

Aye. Doubt we'll get it.

Codein 12-05-2009 04:11 PM

I agree with this and I have done since it was last requested but was given this explanation in a round about way...

Quote:

Graal has dynamic variable names so you can achieve similar results using objects.

Crow 12-05-2009 05:02 PM

Quote:

Originally Posted by Codein (Post 1542652)
I agree with this and I have done since it was last requested but was given this explanation in a round about way...

Maybe Stefan could just real-time translate child objects to work with an associative array syntax. Lua kind of does it as well:
NPC Code:
local arr = { x = 30, y = 40 };
print(arr["x"] .. ", " .. arr.y); -- "30, 40"


Codein 12-05-2009 05:08 PM

Quote:

Originally Posted by Crow (Post 1542664)
Maybe Stefan could just real-time translate child objects to work with an associative array syntax. Lua kind of does it as well:
NPC Code:
local arr = { x = 30, y = 40 };
print(arr["x"] .. ", " .. arr.y); -- "30, 40"


I like that idea! I think I'm gonna have to go try Lua out sometime soon, to be honest >_<

Crono 12-05-2009 05:09 PM

this feature should be implemented im serial guys

coreys 12-05-2009 06:54 PM

Eeewwww, Perl. Lua or Python syntax = way better ;)
I guess the issue why it's never done is because Stefan is entirely too lazy to change anything that involved the syntax, rather than just adding a function or object.

Codein 12-05-2009 06:59 PM

Quote:

Originally Posted by coreys (Post 1542680)
Eeewwww, Perl. Lua or Python syntax = way better ;)
I guess the issue why it's never done is because Stefan is entirely too lazy to change anything that involved the syntax, rather than just adding a function or object.

This isn't really a high priority request in my opinion. It's uses are almost, if not fully, emulated by dynamic naming and objects. It'd be nice, sure, but it's not like it's REALLY needed.


All times are GMT +2. The time now is 10:16 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.