HiddenChest RGSS Player Executable
Using *args for the standard alias + monkey patch pattern increases compatibility. Let me show you some code.

Original:
Code:
class Foo
  def update
    # ...
  end
end

Script Other:
Code:
class Foo
  # ...
  alias_method :other_update, :update
  def update(bar)
    # Do stuff with bar
    other_update
  end
end

The update call path then goes like this: 
() -> Other -> Original -> 

Say I want to attach my own piece of code. Consider this piece of code with args code:
Code:
class Foo
  alias_method :zeriab_example_update, :update
  def update(*args)
    # Do new stuff
    zeriab_example_update(*args)
  end
end

I can place my script both above and below the other script. Both cases works fine.
() -> Other -> With args -> Original -> 
() -> With args -> Other -> Original -> 

Let's look at some code with no args:
Code:
class Foo
  alias_method :zeriab_example_update, :update
  def update
    # Do new stuff
    zeriab_example_update
  end
end

Again you have two possible order arrangements however only one works
() -> Other -> No args -> Original -> 
() -> No args -> Other -> Original -> 

I don't whether there is a performance impact. If not, then it's a case of pure upside. Even with a small perf impact I would often find the price worth paying.


P.s. Ruby supports passing on blocks to method calls. You can access this via the & symbol.
Code:
class Foo
  alias_method :zeriab_example_update, :update
  def update(*args, &block)
    # Do new stuff
    zeriab_example_update(*args, &block)
  end
end
I've found the usage scenarios to be very rare indeed. Only use has pretty much been when I've played around with the Enumerable mixin.
Also, you got to be careful with Procs as they cannot be serialized. If you store it in the object (@my_block = block) then you can no longer serialize that Foo object.

*hugs*
[Image: ZeriabSig.png]
Reply }


Messages In This Thread
HiddenChest RGSS Player Executable - by kyonides - 11-21-2018, 10:44 PM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-22-2018, 06:33 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-25-2018, 12:17 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-25-2018, 05:48 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-26-2018, 12:55 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-26-2018, 04:42 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-27-2018, 08:56 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-28-2018, 11:31 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 11-29-2018, 05:10 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 12-01-2018, 07:15 AM
RE: MKXPPLUS RGSS Player Executable - by Mel - 12-01-2018, 11:11 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 12-06-2018, 05:25 AM
RE: MKXPPLUS RGSS Player Executable - by Mel - 12-07-2018, 12:17 AM
RE: MKXPPLUS RGSS Player Executable - by kyonides - 12-07-2018, 06:20 AM
RE: HiddenChest RGSS Player Executable - by Mel - 12-08-2018, 09:55 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-23-2019, 02:47 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 12:16 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 05:23 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 05:39 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 06:24 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 06:59 AM
RE: HiddenChest RGSS Player Executable - by KDC - 03-26-2019, 09:00 PM
RE: HiddenChest RGSS Player Executable - by Mel - 06-26-2019, 06:12 PM
RE: HiddenChest RGSS Player Executable - by Mel - 06-26-2019, 10:57 PM
RE: HiddenChest RGSS Player Executable - by Mel - 06-27-2019, 08:49 AM
RE: HiddenChest RGSS Player Executable - by KDC - 07-02-2019, 10:09 PM
RE: HiddenChest RGSS Player Executable - by KDC - 07-03-2019, 03:55 PM
RE: HiddenChest RGSS Player Executable - by Mel - 12-11-2019, 11:38 PM
RE: HiddenChest RGSS Player Executable - by Mel - 03-07-2023, 01:39 PM
RE: HiddenChest RGSS Player Executable - by Tepe - 12-10-2024, 07:38 PM
RE: HiddenChest RGSS Player Executable - by Tepe - 12-11-2024, 12:41 AM
RE: HiddenChest RGSS Player Executable - by Zeriab - 12-11-2024, 09:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Neko RMXP Player for Android JayRay 2 8,327 10-05-2014, 03:46 AM
Last Post: DerVVulfman
   ARGSS - Remaking RGSS/2 Player vgvgf 13 22,982 04-21-2010, 04:34 AM
Last Post: vgvgf



Users browsing this thread: 11 Guest(s)