Friend functions or classes

Hi,

I would like to simulate something like friend class or method in Ruby;
From
the pickaxe documentation I could not figure out if there is one
directly
available or not.

I do understand that having friend classes and functions is not good
practice.

Regards,
Kiran.

On Dec 2, 11:02 am, SunRaySon [email protected] wrote:

Regards,
Kiran.

Friend Functions and Friend Classes are often useful for one class to
see the private variables of another class, even though these
variables should probably not be made part of the public interface
that the class supports.

Friend function or friend classes are one of most dangerous
construction. From my experience mostly because programmers tend to
misuse it. I do not want to make this an academic issue so to make
this short: my advice is do not use friend class as a construction in
you code especially if you try to port some C++ algorithm even if that
seams to look like an easy thing to do.

Depending on particular reason, why do you think you have to use the
friend class, I will most probably consider using observer and/or
visitor pattern in stand.

Thanks Dejan. I will try it out.

Kiran.

Hi All,

I’m new to Ruby and I’m trying to script Microsoft Outlook to save
attachments that exceed half a megabyte. I am using WIN32OLE, and
trying to reference Outlook as a COM object. I also downloaded the OLE
browser and am examining the different things I can call. My really
rough, and inexperienced code,
is:
require ‘win32ole’

outlook=WIN32OLE.new(‘Outlook.Application’)

mapi =outlook.GetNameSpace(‘MAPI’)

inbox=mapi.GetDefaultFolder(6)

indox.Items.each do |message|
if message.Attachment.Size > 500,000
message.Attachment.SaveAsFile(‘path to
remote drive’)
end

Any thoughts on this?

Ron

Depending on particular reason, why do you think you have to use the
friend class, I will most probably consider using observer and/or
visitor pattern in stand.

irb(main):001:0> class Foo
irb(main):002:1> private
irb(main):003:1> def cant_see_me
irb(main):004:2> “ouch! found me”
irb(main):005:2> end
irb(main):006:1> end
=> nil
irb(main):007:0> Foo.new.send(‘cant_see_me’)
=> “ouch! found me”

Walking down this path leads to the dark side, the power of the dark
side is strong, you will have powers beyond your wildest imagination.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs